您的位置:首页 > Web前端 > JavaScript

javascript中的querySelector()和querySelectorAll()

2014-06-25 22:23 549 查看
//get the header ID element

document.querySelector("#header");

//get the first element with a dropcap class

document.querySelector(".dropcap");

//get all the paragraphs with a "dropcap" class produces a nodelist

document.querySelectorAll(".dropcap");

//get all elements with a class of "dropcap" or "huge"

document .querySelectorAll(".dropcap,.huge");

//get all paragraphs that hava a class

document.querySelectorAll("p[class]");

浏览器支持度

IE8.0及以上
Firefox3.5及以上
chrome1及更高
opera10及更高
Safari3.2及更高
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: