Prevent default event action


/ Published in: jQuery
Save to your folder(s)

Description: If this method is called, the default action of the event will not be triggered.

For example, clicked anchors will not take the browser to a new URL. We can use event.isDefaultPrevented() to determine if this method has been called by an event handler that was triggered by this event.


Copy this code and paste it in your HTML
  1. $("a").click(function(event) {
  2. event.preventDefault();
  3. //CODE
  4. });

URL: http://api.jquery.com/event.preventDefault/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.