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
Post a Comment