-
-
Save ryanseddon/1009759 to your computer and use it in GitHub Desktop.
select DOM elements by any valid CSS selector
This file contains 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
function( | |
a, // take almost any selector keep it to CSS2.1 valid selector for IE8 support e.g "li,a,p,div:first-child" | |
b // an optional context, you can pass the function itself as a context e.g. fn("li",fn("#id")[0]) make sure you tell it to look at the first array item | |
){ | |
return( // return an element or list, from within the scope of | |
b // the passed context | |
|| document // or document, | |
).querySelectorAll( // qSA lets you pass any valid css selectors and returns a static node list | |
a // pass in CSS selector. | |
) | |
} |
This file contains 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
function(a,b){return(b||document).querySelectorAll(a)} |
This file contains 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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
This file contains 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
{ | |
"name": "cssSelect", | |
"description": "select DOM elements by any valid CSS selector", | |
"keywords": [ | |
"dom", | |
"css", | |
"id", | |
"class", | |
"tag" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment