2010-05-01 155 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()同樣的效果。

相關問題