querySelectorAll

document.querySelectorAll('.mygroup'); //returns all elements with class="mygroup" document.querySelectorAll('option[selected="selected"]'); //returns the default selected option within each SELECT menu document.querySelectorAll('#mytable tr>td:nth-of-type(1)'); //returns the first cell within each table row of "mytable"
使用javascript搜尋DOM,效能比JQUERY好

僅適用於IE8以上版本

http://www.javascriptkit.com/dhtmltutors/css_selectors_api.shtml

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.