3.通过选择器查找
1.queryElementSelector:通过选择器查找,可以查找id名、class名和标签名,但是只能找到一个
用法:
var ele = document.queryElementSelector("#main");
var ele = document.queryElementSelector(".main");
var ele = document.queryElementSelector("input");
- queryElementSelectorAll:这个也是通过选择器查找,可以查找id名、class名和标签名,可以查找所有并返回一个动态集合 [数组]
用法:
var ele = document.queryElementSelectorAll("#main");
var ele = document.queryElementSelectorAll(".main");
var ele = document.queryElementSelectorAll
网友评论