jquery判斷鼠標(biāo)按下去的是左鍵還是右鍵
有時(shí)候開發(fā)需要對(duì)鼠標(biāo)左右鍵進(jìn)行判斷,以下介紹jquery判斷鼠標(biāo)按下去的是左鍵還是右鍵 功能
代碼如下:
代碼如下:
<title>jquery判斷鼠標(biāo)按下去的是左鍵還是右鍵</title> <style> #id1{ cursor:pointer; height:500px; width:500px; border:1px solid #f00; } </style> <script src="jquery.js"></script> <script> $(function(){ $("#id1").mousedown(function(e){ //在div="id1"區(qū)域點(diǎn)擊 switch(e.which){ case 1:{ alert('左鍵'); break; } case 2:{ alert('中間'); break; } case 3:{ alert('右鍵'); break; } } }); }); </script> <script> document.oncontextmenu = function(){return false;}; //屏蔽右鍵菜單 </script> <div id="id1">鼠標(biāo)點(diǎn)擊此區(qū)域</div>
中國(guó)· 上海

添加微信咨詢
關(guān)鍵詞
辦公室:上海市浦東新區(qū)郭守敬路351號(hào)
CopyRight?2009-2019 上海谷谷網(wǎng)絡(luò)科技有限公司 All Rights Reserved. 滬ICP備11022482號(hào)-8
- top
- 在線咨詢
-
添加微信咨詢