javascript - Windows store app - addEventListener on class -


i realize not possible add addeventlistener on document.getelementbyclassname selector. have several buttons identical functionality. can somehow? ok can use id selector, way i'll have add more code lines "needed".

with jquery:

$(".class").on("click", somefunction); 

why not iterate through array returned document.getelementsbyclassname()?

var elements = document.getelementsbyclassname('foo'); (var = 0; < elements.length; i++)    elements[i].addeventlistner('someevent', eventhandler(evt), false); 

it might not succinct jquery equivalent gets job done. alternatively, use jquery in app(personally, haven't tried out).


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -