Javascript library implementing emulation of CSS selectors lookup, as document.querySelector.
View the Project on GitHub jeremiah-shaulov/joyquery
These are CSS features taken from the standard.
Pattern | Meaning | Implemented by joyquery |
---|---|---|
* | any element | yes |
E | an element of type E | yes |
E[foo] | an E element with a "foo" attribute | yes |
E[foo="bar"] | an E element whose "foo" attribute value is exactly equal to "bar" | yes |
E[foo~="bar"] | an E element whose "foo" attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar" | yes |
E[foo^="bar"] | an E element whose "foo" attribute value begins exactly with the string "bar" | yes |
E[foo$="bar"] | an E element whose "foo" attribute value ends exactly with the string "bar" | yes |
E[foo*="bar"] | an E element whose "foo" attribute value contains the substring "bar" | yes |
E[foo|="en"] | an E element whose "foo" attribute has a hyphen-separated list of values beginning (from the left) with "en" | yes |
E:root | an E element, root of the document | yes |
E:nth-child(n) | an E element, the n-th child of its parent | yes |
E:nth-last-child(n) | an E element, the n-th child of its parent, counting from the last one | yes |
E:nth-of-type(n) | an E element, the n-th sibling of its type | yes |
E:nth-last-of-type(n) | an E element, the n-th sibling of its type, counting from the last one | yes |
E:first-child | an E element, first child of its parent | yes |
E:last-child | an E element, last child of its parent | yes |
E:first-of-type | an E element, first sibling of its type | yes |
E:last-of-type | an E element, last sibling of its type | yes |
E:only-child | an E element, only child of its parent | yes |
E:only-of-type | an E element, only sibling of its type | yes |
E:empty | an E element that has no children (including text nodes) | yes |
E:link | a link element (<a> with href attribute) | yes, works like querySelector (selects also visited links) |
E:visited | a visited link | yes, works like querySelector (selects nothing) |
E:active | a link being clicked | not in library, See how to add it |
E:hover | a link under mouse | not in library, See how to add it |
E:focus | an E element during certain user actions | yes |
E:target | an E element being the target of the referring URI | yes |
E:lang(fr) | an element of type E in language "fr" (the document language specifies how language is determined) | not in library, See how to add it |
E:enabled E:disabled |
a user interface element E which is enabled or disabled | yes |
E:checked | a user interface element E which is checked (for instance a radio-button or checkbox) | yes |
E::first-line | the first formatted line of an E element | no, doesn't select an element |
E::first-letter | the first formatted letter of an E element | no, doesn't select an element |
E::before | generated content before an E element | no, doesn't select an element |
E::after | generated content after an E element | no, doesn't select an element |
E.warning | an E element whose class is "warning" (the document language specifies how class is determined) | yes |
E#myid | an E element with ID equal to "myid" | yes |
E:not(s) | an E element that does not match simple selector s | yes, extended to complex selector |
E F | an F element descendant of an E element | yes |
E > F | an F element child of an E element | yes |
E + F | an F element immediately preceded by an E element | yes |
E ~ F | an F element preceded by an E element | yes |
These features are not found in standard, but implemented by joyquery:
Pattern | Meaning |
---|---|
E[foo!="bar"] | an E element that either doesn't have "foo" attribute, or has it with value not equal to "bar" |
:javascript-func | Javascript function to test elements |
axis::E | One of the following axises like in XPATH: self, child, descendant, descendant-or-self, parent, ancestor, ancestor-or-self, following-sibling, first-following-sibling, preceding-sibling, first-preceding-sibling |
E:has(s) | an E element that also matches selector s |
E:any(s1, s2, ...) | an E element that also matches any of given selectors s1, s2, ... |
E:hidden | an E element that doesn't occupy space (display:none, type="hidden", etc...) |
E:input | an E element which is INPUT, SELECT, TEXTAREA or BUTTON |
:from(n) | When applied to a simple selector, e.g. E.cls, selects only elements starting from number n in matched set |
:limit(n) | When applied to a simple selector, e.g. E.cls, limits matched set to no more than n elements |