javascript - Select all links and forms without jQuery -
javascript - Select all links and forms without jQuery -
how can select a , form tags without needing include jquery?
i trying following:
$("a").click(function { window.onbeforeunload = null; }); $("form").submit(function { window.onbeforeunload = null; }); but rather not include jquery (or sizzle.js), if there's more compact way that.
you can utilize document.queryselectorall() this:
var els = document.queryselectorall( 'a' ); for( var i=els.length; i--; ) { els[i].addeventlistener( 'click', function(){ window.onbeforeunload = null; } ); } similar <form> tags.
it available in modern browsers (caniuse.com).
javascript jquery selector sizzle
Comments
Post a Comment