2010-05-01 160 views

回答

2

jQuery的Event object实现stopPropagation方法,是一个跨浏览器的方式,以防止冒泡DOM树事件。例如:

// when an anchor with id of someElement gets clicked 
$("#someElement").click(function(e) { 
    e.stopPropagation(); 
}); 

请记住,return false与调用都e.preventDefault()e.stopPropagation()同样的效果。

相关问题