Jquery 监听回车事件与右键事件

Posted ·588 Views·268 Words

在指定ID的区域内监听回车事件:

$("#send_content").bind("keydown", function(e) {
        // 兼容FF和IE和Opera    
        var theEvent = e || window.event;
        var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
        if (code == 13){
            ...
        }
});

 

在指定ID的区域内监听右键事件「左键可使用.click()」:

$("p").mousedown(function(e) {
        if (3 == e.which) {
            ...
        }
})

 

Comments

Leave a comment to join the discussion