Supported CSS Selectors
(CSS 1, CSS 2, CSS 3)
With the DOMAssistant Core module and its $ method comes support for using CSS selectors to get a reference to one or multiple elements. There is support for any major CSS element selector in CSS 1, CSS 2 and CSS 3, with the exact same syntax as you would use in a CSS file.
For an in-depth explanation of the CSS selectors and examples of how us them, please read CSS 2.1 selectors and CSS 3 selectors explained.
Implemented CSS selectors
#container- Get an element with the id "container".
.item- Get all elements with the class name "item".
#container.item- Get an element with the id "container", if it also has the class name "item".
p.info.error- Get all
Pelements with both a class name consisting of both "info" and "item". div p- Get all
Pelements which are descendants of anyDIVelement. div > p- Get all
Pelements which are direct descendants of anyDIVelement. div + p- Get all
Pelements where their immediate previous sibling element is aDIVelement. div ~ p- Get all
Pelements which are following siblings to aDIVelement (not necessarily immediate siblings). div[id]- Get any
DIVelement which has anIDattribute. div[id=container]- Get any
DIVelement which has anIDattribute with the value of "container". input[type=text][value=Yes]- Get any
INPUTelement which has aTYPEattribute with the value of "text" and aVALUEattribute which is ="Yes". div[id^=empt]- Get any
DIVelement where theIDattribute value begins with "empt". div[id$=parent]- Get any
DIVelement where theIDattribute value ends with "parent". div[id*=mpt]- Get any
DIVelement where theIDattribute value contains the text "mpt". div[foo~=bar]- Get any
DIVelement where thefooattribute is a list of space-separated values, one of which is exactly equal to "bar". div[lang|=en]- Get any
DIVelement where thelangattribute has a hyphen-separated list of values beginning (from the left) with "en". div:first-child- Get any
DIVelement which is the first child of its parent element. div:last-child- Get any
DIVelement which is the last child of its parent. div:only-child- Get any
DIVelement which is the only child of its parent. div#container p:first-of-type- Get the
Pelement which is the firstPelement child of aDIVelement with anIDattribute with the value "container". p:last-of-type- Get the
Pelement which is the lastPelement child of its parent element. p:only-of-type- Get any
Pelement which is the onlyPelement child of its parent element. p:nth-of-type(7)- Get the
Pelement which is the 7thPelement child of its parent element. div:empty- Get any
DIVelement which is completely empty (including text nodes). div:not([id=container])- Get any
DIVelement where itsIDattribute is not "container". div:nth-child(3)- Get any
DIVelement which is the third child element of its parent element. div:nth-child(odd)- Get every odd
DIVchild element of its parent element. div:nth-child(even)- Get every even
DIVchild element of its parent element. div:nth-child(5n+3)- Get every 5th
DIVchild element of its parent element, starting at 3, then 8, 13, 18 etc. tr:nth-last-of-type(-n+3)- Get the last three rows of any tables.
td:nth-last-child(n+1)- Get all but the last column of any tables.
input:enabled- Get any
INPUTelement which is enabled. input:disabled- Get any
INPUTelement which is disabled. input:checked- Get any
INPUTelement which is checked. div:lang(zh)- Get any
DIVelement which is in Chinese. p:target- Get the
Pelement which is the target of the referring URL. p, a- Get all
Pelements and allAelements.
