私は、特別なクラス(ライブ)を使ってdivにleft-&のrightclickを管理するには素晴らしいソリューションが必要です。
コードはすべての新しいブラウザで動作することが重要です。Jqueryの右クリック、コンテキストメニューなし、ライブとすべてのブラウザ
誰かが私を助けることを望みます。
私の最初の試み... //右クリックは動作しません
HTML
<div id="test_one" class="my_class">Click here</div>
<br /><br />
<div id="test_two" class="my_class">Click here</div>
JS
$(document).ready(function test()
{
$(".my_class").bind("contextmenu",function(e){ return false; });
$(".my_class").live('click', function(e)
{
if(e.button == 0 || e.button == 1)
{
alert('L -> '+this.id+'');
}
else if(e.button == 2){
alert('R -> '+this.id+'');
}
});
});
ありがとうございます! Peter
可能な複製http://stackoverflow.com/questions/1206203/how-to-distinguish-left-mouse-click-and-right-with-jquery – Alpesh
このリンクでも同じ質問が含まれています。http:// stackoverflow .com/questions/4007482/jquery-detect-middle-or-right-mouse-button-click-if-do-do-this-this – Alpesh