Javascript native equivalent for jQuery event.preventDefault

Possible Duplicate:
event.preventDefault() vs. return false

I'm not sure, but as far as I see, event.preventDefault is coming from jQuery . if yes, I'm wondering is there any native equivalent in Javascript doing the same?


preventDefault is a DOM method. See the W3C specification here.


jQuery wrap around native JavaScript event object. preventDefault is JavaScript method. you can achieve preventDefault in jQuery by return false; .


return false from within a jQuery event handler is effectively the same as calling both e.preventDefault and e.stopPropagation on the passed jQuery.Event object.

e.preventDefault() will prevent the default event from occuring, e.stopPropagation() will prevent the event from bubbling up and return false will do both. Note that this behaviour differs from normal (non-jQuery) event handlers, in which, notably, return false does not stop the event from bubbling up.

Source: https://stackoverflow.com/a/1357151

链接地址: http://www.djcxy.com/p/19516.html

上一篇: e.preventDefault()方法真的做什么?

下一篇: Javascript原生等同于jQuery event.preventDefault