可能重複:
How to distinguish between left and right mouse click with jQueryjQuery的點擊鼠標右鍵格
如何打開上下文meniu當我在div內點擊鼠標右鍵點擊。因爲當我點擊鼠標右鍵內div其淡出?
的Javascript
$("#link").click(function(e){
e.stopPropagation();
div = $("#mydiv").fadeToggle(300);
});
$("#mydiv").click(function(e){
e.stopPropagation();
});
$(document).click(function(e){
$('#mydiv').fadeOut(200);
});
HTML
<a id="link">Click</a>
<div id="mydiv" style="width: 200px; height: 200px;">Hello</div>
UPDATE:
的Javascript
$("#link").click(function(e){
e.stopPropagation();
div = $("#mydiv").fadeToggle(300);
});
$("#good_buttom").click(function(e){
e.stopPropagation();
div = $("#hide").fadeToggle(300);
});
$("#mydiv").mousedown(function(e) {
switch (e.which) {
case 1:
e.stopPropagation();
$('#mydiv').fadeOut(200);
break;
case 2:
alert('2');
break;
case 3:
alert('3');
break;
default:
alert('You have a strange mouse');
}
});
HTML
<a id="link">Click</a>
<div id="mydiv" style="width: 200px; height: 200px;">
<button id="good_button">Click IT</button>
<div id="hide" style="display:none;">Show up.</div>
</div>
嗨,我在這篇文章看,但不明白...我是新的jquery ...任何幫助? – andys