Skip to content

Instantly share code, notes, and snippets.

@ryanseddon
Forked from 140bytes/LICENSE.txt
Created June 6, 2011 04:51
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanseddon/1009759 to your computer and use it in GitHub Desktop.
Save ryanseddon/1009759 to your computer and use it in GitHub Desktop.
select DOM elements by any valid CSS selector
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.
)
}
function(a,b){return(b||document).querySelectorAll(a)}
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.
{
"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