<!-- javascript代碼開始 -->
$(document).ready(function() {
$("div").mousedown(function(e){//div爲被創建的dom
if(3 == e.which){
alert("這 是右鍵單擊事件");
}else if(1 == e.which){
alert("這 是左鍵單擊事件");
}
})
});
<!-- javascript代碼結束 -->
<!-- html開始 -->
<div class="demo1" style="color:green;">
右鍵點此
</div>
<!-- html結束 -->
必須引用jquery的包