What is the argument for?
$(document).ready(function(){
$('#something ul a').click(function(e) {
...
...
e.preventDefault();
})
});
what is the e for and the e.preventDefault mean so i can understand what is happening here
The e
argument is the event
object.
It contains information about the click event.
For more information, see the documentation.
The preventDefault()
method prevents the borwser's default action for the event.
In this case, it will prevent the browser from navigating to the link.
It's preventing the default action of the event, e.g. going to the URL, or scrolling the page to the #location
in the href
.
The first argument to any event handler in jQuery is the event object itself.
e
is the event object, and prevent default is one of its functions.
E
is event and preventDefaults
prevents browser from performing a standard operation in response to such an event. For instance if this is a click event on a link, preventDefaults
whould prevent browser from redirecting to a linked page.
The preventDefault() method prevents the borwser's default action for the event. In this case, it will prevent the browser from navigating to the link. shareedit
精彩评论