Search

10/13/2013

Thomas Peklak : Iterate over querySelectorAll result

Thomas Peklak : Iterate over querySelectorAll result

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);
  }
);

沒有留言: