Last active
January 24, 2017 09:04
-
-
Save electerious/b49d7c295aac629779b2 to your computer and use it in GitHub Desktop.
Select multiple elements and receive an array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const select = (query, elem = null) => { | |
elem = (elem==null ? document : elem) | |
let elems = elem.querySelectorAll(query) | |
if (elems==null) return [] | |
else return Array.prototype.slice.call(elems, 0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: