Wednesday, April 15, 2015

jQuery event.preventDefault() Method

The event.preventDefault() method stops the default action of an element from happening.
For example:
  • Prevent a submit button from submitting a form
  • Prevent a link from following the URL

$("a").click(function(event){
    event.preventDefault();
});

Prevent a link from opening the URL:

No comments:

Post a Comment