Prevent Default on Form Submit jQuery
Try this: $(“#cpa-form”).submit(function(e){ return false; });
Try this: $(“#cpa-form”).submit(function(e){ return false; });
in IE, you can use event.returnValue = false; to achieve the same result. And in order not to get an error, you can test for the existence of preventDefault: if(event.preventDefault) event.preventDefault(); You can combine the two with: event.preventDefault ? event.preventDefault() : (event.returnValue = false);
As per commented by @Prescott, the opposite of: evt.preventDefault(); Could be: Essentially equating to ‘do default’, since we’re no longer preventing it. Otherwise I’m inclined to point you to the answers provided by another comments and answers: How to unbind a listener that is calling event.preventDefault() (using jQuery)? How to reenable event.preventDefault? Note that the … Read more
According to the docs for ngHref you should be able to leave off the href or do href=””. <input ng-model=”value” /><br /> <a id=”link-1″ href ng-click=”value = 1″>link 1</a> (link, don’t reload)<br /> <a id=”link-2″ href=”” ng-click=”value = 2″>link 2</a> (link, don’t reload)<br /> <a id=”link-4″ href=”” name=”xx” ng-click=”value = 4″>anchor</a> (link, don’t reload)<br /> … Read more
stopPropagation prevents further propagation of the current event in the capturing and bubbling phases. preventDefault prevents the default action the browser makes on that event. Examples preventDefault $(“#but”).click(function (event) { event.preventDefault() }) $(“#foo”).click(function () { alert(“parent click event fired!”) }) <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script> <div id=”foo”> <button id=”but”>button</button> </div> stopPropagation $(“#but”).click(function (event) { event.stopPropagation() }) $(“#foo”).click(function () … Read more