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

Popular posts from this blog

javascript - mongodb won't find my schema method in nested container -

Hibernate criteria by a list of natural ids -

ios - Lagging ScrollView with UIWebview inside -