Where developers come to connect, share, build and be inspired.

7

Iterate over querySelectorAll result

10142 views


querySelectorAll results do not provide a way to iterate over them (what a shame!), it should be as simple as:

document.querySelectorAll('.failure').forEach(function(){
  doStuff()
});

nevertheless you can iterate with:

[].forEach.call(
  document.querySelectorAll('.awsome'), 
  function(el){
    doStuffWith(el);
  }
);

Comments

Add a comment