Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Created February 16, 2009 18:07
Show Gist options
  • Select an option

  • Save subtleGradient/65275 to your computer and use it in GitHub Desktop.

Select an option

Save subtleGradient/65275 to your computer and use it in GitHub Desktop.
$$('*') === document.getElementsByTagName('*')
$$('A') === document.getElementsByTagName('A')
$$('A[foo]') === document.getElementsByTagName('A').filterBy(hasAttribute('foo'))
$$('A[foo="bar"]') === document.getElementsByTagName('A').filterBy(hasAttribute('foo','bar'))
$$('A[foo~="bar"]') === document.getElementsByTagName('A').filterBy(hasAttribute('foo','bar',' '))
$$('A[hreflang|="en"]') === document.getElementsByTagName('A').filterBy(hasAttribute('hreflang','en','|'))
$$('A[foo^="bar"]') === document.getElementsByTagName('A').filterBy(hasAttribute('foo',/^bar/))
$$('A[foo$="bar"]') === document.getElementsByTagName('A').filterBy(hasAttribute('foo',/bar$/))
$$('A[foo*="bar"]') === document.getElementsByTagName('A').filterBy(hasAttribute('foo',/bar/))
$$('A:first-child') === document.getElementsByTagName('A').filterBy(get('first-child'))
$$('A:root') === document.getElementsByTagName('A').filterBy(get('root'))
$$('A:nth-child(n)') === document.getElementsByTagName('A').filterBy(get('nth-child','n'))
$$('A:nth-last-child(n)') === document.getElementsByTagName('A').filterBy(get('nth-last-child','n'))
$$('A:nth-of-type(n)') === document.getElementsByTagName('A').filterBy(get('nth-of-type','n'))
$$('A:nth-last-of-type(n)') === document.getElementsByTagName('A').filterBy(get('nth-last-of-type','n'))
$$('A:last-child') === document.getElementsByTagName('A').filterBy(get('last-child'))
$$('A:first-of-type') === document.getElementsByTagName('A').filterBy(get('first-of-type'))
$$('A:last-of-type') === document.getElementsByTagName('A').filterBy(get('last-of-type'))
$$('A:only-child') === document.getElementsByTagName('A').filterBy(get('only-child'))
$$('A:only-of-type') === document.getElementsByTagName('A').filterBy(get('only-of-type'))
$$('A:empty') === document.getElementsByTagName('A').filterBy(get('empty'))
$$('A:link') === document.getElementsByTagName('A').filterBy(get('link'))
$$('A:visited') === document.getElementsByTagName('A').filterBy(get('visited'))
$$('A:active') === document.getElementsByTagName('A').filterBy(get('active'))
$$('A:hover') === document.getElementsByTagName('A').filterBy(get('hover'))
$$('A:focus') === document.getElementsByTagName('A').filterBy(get('focus'))
$$('A:lang(fr)') === document.getElementsByTagName('A').filterBy(get('lang','fr'))
$$('A:target') === document.getElementsByTagName('A').filterBy(get('target'))
$$('A:disabled') === document.getElementsByTagName('A').filterBy(get('disabled'))
$$('A:enabled') === document.getElementsByTagName('A').filterBy(get('enabled'))
$$('A:checked') === document.getElementsByTagName('A').filterBy(get('checked'))
$$('A::first-line') === document.getElementsByTagName('A').filterBy(get('first-line'))
$$('A::first-letter') === document.getElementsByTagName('A').filterBy(get('first-letter'))
$$('A::before') === document.getElementsByTagName('A').filterBy(get('before'))
$$('A::after') === document.getElementsByTagName('A').filterBy(get('after'))
$$('A::selection') === document.getElementsByTagName('A').filterBy(get('selection'))
$$('A.warning') === document.getElementsByTagName('A').filterBy(hasAttribute('class','warning'))
$$('A#myid') === document.getElementsByTagName('A').filterBy(hasAttribute('id','myid'))
$$('A#myid') === document.getElementById('myid').filterBy(getTagName('A'))
$$('A B') === document.getElementsByTagName('A').getElementsByTagName('B')
$$('A > B') === document.getElementsByTagName('A').getChildren().filterBy(hasTagName('B'))
$$('A + B') === document.getElementsByTagName('A').getSibling() .filterBy(hasTagName('B'))
$$('A ~ B') === document.getElementsByTagName('A').getSiblings().filterBy(hasTagName('B'))
$$('A:not(B)') === document.getElementsByTagName('A').filterBy(notTagName('B'))
$$('A:not(*)') === document.getElementsByTagName('A').filterBy(notTagName('*'))
$$('A:not([foo])') === document.getElementsByTagName('A').filterBy(notAttribute('foo'))
$$('A:not([foo="bar"])') === document.getElementsByTagName('A').filterBy(notAttribute('foo','bar'))
$$('A:not([foo~="bar"])') === document.getElementsByTagName('A').filterBy(notAttribute('foo','bar',' '))
$$('A:not([hreflang|="en"])') === document.getElementsByTagName('A').filterBy(notAttribute('hreflang','en','|'))
$$('A:not([foo^="bar"])') === document.getElementsByTagName('A').filterBy(notAttribute('foo',/^bar/))
$$('A:not([foo$="bar"])') === document.getElementsByTagName('A').filterBy(notAttribute('foo',/bar$/))
$$('A:not([foo*="bar"])') === document.getElementsByTagName('A').filterBy(notAttribute('foo',/bar/))
$$('A:not(:first-child)') === document.getElementsByTagName('A').filterBy(not('first-child'))
$$('A:not(:root)') === document.getElementsByTagName('A').filterBy(not('root'))
$$('A:not(:nth-child(n))') === document.getElementsByTagName('A').filterBy(not('nth-child','n'))
$$('A:not(:nth-last-child(n))') === document.getElementsByTagName('A').filterBy(not('nth-last-child','n'))
$$('A:not(:nth-of-type(n))') === document.getElementsByTagName('A').filterBy(not('nth-of-type','n'))
$$('A:not(:nth-last-of-type(n))') === document.getElementsByTagName('A').filterBy(not('nth-last-of-type','n'))
$$('A:not(:last-child)') === document.getElementsByTagName('A').filterBy(not('last-child'))
$$('A:not(:first-of-type)') === document.getElementsByTagName('A').filterBy(not('first-of-type'))
$$('A:not(:last-of-type)') === document.getElementsByTagName('A').filterBy(not('last-of-type'))
$$('A:not(:only-child)') === document.getElementsByTagName('A').filterBy(not('only-child'))
$$('A:not(:only-of-type)') === document.getElementsByTagName('A').filterBy(not('only-of-type'))
$$('A:not(:empty)') === document.getElementsByTagName('A').filterBy(not('empty'))
$$('A:not(:link)') === document.getElementsByTagName('A').filterBy(not('link'))
$$('A:not(:visited)') === document.getElementsByTagName('A').filterBy(not('visited'))
$$('A:not(:active)') === document.getElementsByTagName('A').filterBy(not('active'))
$$('A:not(:hover)') === document.getElementsByTagName('A').filterBy(not('hover'))
$$('A:not(:focus)') === document.getElementsByTagName('A').filterBy(not('focus'))
$$('A:not(:lang(fr))') === document.getElementsByTagName('A').filterBy(not('lang','fr'))
$$('A:not(:target)') === document.getElementsByTagName('A').filterBy(not('target'))
$$('A:not(:disabled)') === document.getElementsByTagName('A').filterBy(not('disabled'))
$$('A:not(:enabled)') === document.getElementsByTagName('A').filterBy(not('enabled'))
$$('A:not(:checked)') === document.getElementsByTagName('A').filterBy(not('checked'))
$$('A:not(::first-line)') === document.getElementsByTagName('A').filterBy(not('first-line'))
$$('A:not(::first-letter)') === document.getElementsByTagName('A').filterBy(not('first-letter'))
$$('A:not(::before)') === document.getElementsByTagName('A').filterBy(not('before'))
$$('A:not(::after)') === document.getElementsByTagName('A').filterBy(not('after'))
$$('A:not(::selection)') === document.getElementsByTagName('A').filterBy(not('selection'))
$$('A:not(.warning)') === document.getElementsByTagName('A').filterBy(notAttribute('class','warning'))
$$('A:not(#myid)') === document.getElementsByTagName('A').filterBy(notAttribute('id','myid'))
$$('#nav li.menuitem>a') ===
document.getElementById('nav')
.getElementsByTagName('li')
.filterBy(hasAttribute('class','menuitem'))
.getChildren()
.filterBy(hasTagName('a'))
;
myForm.getElements('[type=text].aswome') === myForm.getElementsByTagName('*').filterBy(hasAttribute('type','text'), hasAttribute('class','aswome'));
myForm.getElements('[type=text].aswome') === myForm.getElementsByTagName('*').filterBy({ 'type':'text', 'class':'aswome' });
/* FIRST DEFINED IN CSS LEVEL MEANING DESCRIBED IN SECTION */
'E' /* 1 an element of type E Type selector */
'*' /* 2 any element Universal selector */
'E[foo]' /* 2 an E element with a "foo" attribute Attribute selectors */
'E[foo="bar"]' /* 2 an E element whose "foo" attribute value is exactly equal to "bar" Attribute selectors */
'E[foo~="bar"]' /* 2 an E element whose "foo" attribute value is a list of space-separated values, one of which is exactly equal to "bar" Attribute selectors */
'E[hreflang|="en"]' /* 2 an E element whose "hreflang" attribute has a hyphen-separated list of values beginning (from the left) with "en" Attribute selectors */
'E[foo^="bar"]' /* 3 an E element whose "foo" attribute value begins exactly with the string "bar" Attribute selectors */
'E[foo$="bar"]' /* 3 an E element whose "foo" attribute value ends exactly with the string "bar" Attribute selectors */
'E[foo*="bar"]' /* 3 an E element whose "foo" attribute value contains the substring "bar" Attribute selectors */
'E:first-child' /* 2 an E element, first child of its parent Structural pseudo-classes */
'E:root' /* 3 an E element, root of the document Structural pseudo-classes */
'E:nth-child(n)' /* 3 an E element, the n-th child of its parent Structural pseudo-classes */
'E:nth-last-child(n)' /* 3 an E element, the n-th child of its parent, counting from the last one Structural pseudo-classes */
'E:nth-of-type(n)' /* 3 an E element, the n-th sibling of its type Structural pseudo-classes */
'E:nth-last-of-type(n)' /* 3 an E element, the n-th sibling of its type, counting from the last one Structural pseudo-classes */
'E:last-child' /* 3 an E element, last child of its parent Structural pseudo-classes */
'E:first-of-type' /* 3 an E element, first sibling of its type Structural pseudo-classes */
'E:last-of-type' /* 3 an E element, last sibling of its type Structural pseudo-classes */
'E:only-child' /* 3 an E element, only child of its parent Structural pseudo-classes */
'E:only-of-type' /* 3 an E element, only sibling of its type Structural pseudo-classes */
'E:empty' /* 3 an E element that has no children (including text nodes) Structural pseudo-classes */
'E:link' /* 1 an E element being the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited) The link pseudo-classes */
'E:visited' /* 1 */
'E:active' /* 1 */
'E:hover' /* 1 and 2 an E element during certain user actions The user action pseudo-classes */
'E:focus' /* 1 and 2 */
'E:lang(fr)' /* 2 an element of type E in language "fr" (the document language specifies how language is determined) The :lang() pseudo-class */
'E:target' /* 3 an E element being the target of the referring URI The target pseudo-class */
'E:disabled' /* 3 a user interface element E which is enabled or disabled The UI element states pseudo-classes */
'E:enabled' /* 3 */
'E:checked' /* 3 a user interface element E which is checked (for instance a radio-button or checkbox) The UI element states pseudo-classes */
'E::first-line' /* 1 the first formatted line of an E element The ::first-line pseudo-element */
'E::first-letter' /* 1 the first formatted letter of an E element The ::first-letter pseudo-element */
'E::before' /* 2 generated content before an E element The ::before pseudo-element */
'E::after' /* 2 generated content after an E element The ::after pseudo-element */
'E::selection' /* 3 the portion of an E element that is currently selected/highlighted by the user The UI element fragments pseudo-elements*/
'E.warning' /* 1 an E element whose class is "warning" (the document language specifies how class is determined). Class selectors */
'E#myid' /* 1 an E element with ID equal to "myid". ID selectors */
'E F' /* 1 an F element descendant of an E element Descendant combinator */
'E > F' /* 2 an F element child of an E element Child combinator */
'E + F' /* 2 an F element immediately preceded by an E element Adjacent sibling combinator */
'E ~ F' /* 3 an F element preceded by an E element General sibling combinator */
'E:not(s)' /* 3 an E element that does not match simple selector s Negation pseudo-class */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment