An exciting development in the world of DOM scripting is the W3C Selector API. Up until now, using the DOM Level 2 API, the only way to obtain references to HTML elements in the DOM was to use either document.getElementById or document.getElementsByTagName and filter the results manually. With the rise of CSS, JavaScript programmers asked the obvious question, “If the browser has a really fast way of selecting HTML elements that match CSS selectors why can’t we?”.
The Selector API defines the querySelector, and querySelectorAll methods that take a CSS selector string and return the first matching element or a StaticNodeList of matching elements, respectively. The methods can be called from the document object in order to select elements from the whole document or a specific HTML element to select only from descendants of that element.
- Source: http://www.sitepoint.com/
Popularity: 1% [?]
Did you like this? If so, please bookmark it, about it, and subscribe to the blog RSS feed.





Leave a Reply