javascript advance selector
Define in W3C Selectors API
, used to locate element in document by CSS rule
.
IE >= 8, Firefox, Chrome, Safari, Opera support them.
1 | module dom { |
Document, DocumentFragment, Element implements NodeSelector interface.
The difference is querySelector return an object
, querySelectorAll return a collection
(NodeList).
1 | document.getElementById("test"); |
1 | document.getElementsByClassName('red') |
Difference between jQuery(element).find(selector)
1 | <div id="test1"><a href="http://www.linchenguang.com/">lcg</a></div> |
querySelectorAll
find element in DOM, contain Element it’s self.jQuery(element).find(selector)
find element in DOM, not contain Element it’s self.