javascript - How to stop default link click behavior with jQuery -




i have link on webpage. when user clicks it, widget on page should update. however, doing something, because default functionality (navigating different page) occurs before event fires.

this link looks like:

  <a href="store/cart/" class="update-cart">update cart</a> 

this jquery looks like:

   $('.update-cart').click(function(e) {           e.stoppropagation();           updatecartwidget();        }); 

what problem?

e.preventdefault(); 

from https://developer.mozilla.org/en-us/docs/web/api/event.preventdefault

cancels event if cancelable, without stopping further propagation of event.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -