views:

61

answers:

4
$(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

+5  A: 

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.

SLaks
+1  A: 

e is the event object, and prevent default is one of its functions.

David
+2  A: 

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.

Nick Craver
+1  A: 

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.

mgamer