jquery - Javascript - cannot stop link from loading page -
i have link element (actually, links of class) have bound click event.
here's example link element:
<a id="2" class="paginationclick" style="cursor: pointer;" href="">2</a>
and here's binding:
$(".paginationclick").click(function(e) { displayaccountsearchresults(e); if (e.stoppropagation) { e.stoppropagation(); } else { e.cancelbubble = true; } });
displayaccountsearchresults(e) executes fine page reloads. not want page reload. why isn't stoppropagation / cancelbubble working?
you need e.preventdefault
$(".paginationclick").click(function(e) { e.preventdefault() displayaccountsearchresults(e); if (e.stoppropagation) { e.stoppropagation(); } else { e.cancelbubble = true; } });
Comments
Post a Comment