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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -