Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  let queryAll = (q: string): HTMLElement[] => {
    let nodes = document.querySelectorAll(q);
    return Array.from(nodes).filter(node => (node instanceof HTMLElement)) as HTMLElement[];
  }
Will do the same. Note that `Array.from()` is a relatively new method, that you will need to polyfill if you wish to support internet explorer, but `Array.prototype.slice.call()` serves the same purpose and can be used in older browsers.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: