Questions tagged [preventdefault]

Javascript event method to cancel the event if it is cancelable, without stopping further propagation of the event.

Javascript event method to cancel the event if it is cancelable, without stopping further propagation of the event.

960 questions
27
votes
10 answers

Prevent a link, confirm and then goto location jquery

I have links like this. Delete If a user click on it. A confirmation should popup and then only if user click yes, it should goto the actual url. I know that this can prevent the default behavior …
esafwan
  • 17,311
  • 33
  • 107
  • 166
27
votes
7 answers

Use of getPreventDefault() is deprecated. Use defaultPrevented instead. Why I'm getting this error and what's the solution for it?

Previously I was using jQuery 1.7.1 in my code. I was getting the above error. Then I used the jQuery 1.11.1 straight from the google repository but still I'm…
PHPLover
  • 1
  • 51
  • 158
  • 311
24
votes
1 answer

event.preventDefault() always just before the end of the functions

In almost all the examples / templates scripts I can find, I see event.preventDefault(); at the end of the function, like this: $('.navbar-nav li a').bind('click', function(event) { var $anchor = $(this); $('html, body').stop().animate({ …
Olivier Pons
  • 15,363
  • 26
  • 117
  • 213
23
votes
5 answers

Prevent submit button with onclick event from submitting

I want to prevent a submit button with onclick event from submitting: $j('form#userForm .button').click(function(e) { if ($j("#zip_field").val() > 1000){ $j('form#userForm .button').attr('onclick','').unbind('click'); …
user1054080
21
votes
1 answer

How to make undo work in an HTML textarea after setting the value?

I have a