Seek is a pure-JavaScript CSS selector engine using browser native API. We used native API to make it lightweight. It provide a convenience to find elements for manipulation.
- querySelectorAll
- getElementById
- getElementsByTagName
- getElementsByClassName
A browers must support the native function of 'querySelectorAll'.
As such, the following browsers are supported:
- Chrome 16+
- Edge 12+
- Firefox 3.6+
- Internet Explorer 9+
seek( String selector [, DOMNode context [, Array result]] )
The main function for finding elements. use 'querySelectorAll'
.
Parameters
-
selector
: A CSS selector. -
context
: An element, document, or document fragment to use as the context for finding elements.( Defaults : window.document )
-
result
: An array.
Return
returns
: All elements matching the selector.
seek
supports CSS3 Selector and some functional selector.
And results returned in document order.
As such, the following pseudo-selectors are not supported:
- :hover
- :active
- :visit, :link
As such, the follwing functional selector:
:first/:last
: the first/last matching element.:even/:odd
: Even/odd-numbered elements.:eq(NUMBER)/:nth(NUMBER)
: the nth element. ':eq(1)' finds the second element.:lt(NUMBER)/:gt(NUMBER)
: Elements at positions above/below the specified position.:contains(TEXT)
: Elements with textContent containing the word 'TEXT'.
Example
// Finds odd table rows.
var elems = seek( "#content-table tr:odd" )
Open the test/index.html on a web browser.
GNU Lesser General Public License version 2.1.