const flagR=true; $('.AdministrationT').mousedown(function (e) { alert(e.which) //判斷鼠標點擊的是什么鍵 1:左鍵 2:滾輪 3:右鍵 if (e.which == 3) { if (flagR) { flagR = false; $('.forbiddenJs').css({ display: 'block' }) } else { flagR = true; $('.forbiddenJs').css({ display: 'none' }) } } }) // 阻止瀏覽器右鍵默然彈出框 // document.oncontextmenu = function () { // return false // };