javascript - Link versus onClick -
i have web application exclusively uses ajax there no full refreshes , set
<a href="javascript:...()">
it works on chrome , firefox ie asks confirm page reload every time click on anything. better change links to
href="#"
and make functionality onclick?
thanks.
just stop using inline javascript together. don't need it.
output id associated element in data attribute:
<a href="#" data-id="34" class="list-item">listitem1</a>
now can bind click events external js file:
$(document).ready(function(){ $(".list-item").click(function(e){ e.preventdefault(); // stop jump top var theid = $(this).attr("data-id"); // id somefunction(theid); // execute terribly written function }); });
this does work cross-browser.
Comments
Post a Comment