Is there any difference between these two? Or is just one an abbreviation of the other?
e.preventDefault() and 开发者_如何学Pythonevent.preventDefault()
Well, the only difference is the name of event object that is being passed into your listener. If you declare the listener like this:
a.click(function(e) {
});
Obviously the name of event variable is "e" and you should call e.preventDefault. In the second case:
a.click(function(event) {
});
the name of the event object is "event", so you're calling event.preventDefault()
e is just an abbreviation for event, it depends on how the argument is accepted
It's just a matter of variable naming. Some people's convention is naming their event variable e, ev, or event. Whichever best suits you.
精彩评论