查找html元素_html/css_WEB-ITnose

Lisa Kudrow
Release: 2016-06-24 11:38:01
Original
1261 people have browsed it

一、

通过id找到html元素

document.getElementById();

二、

通过标签名查找html元素

document.getElementsByTagName();

三、

通过类名查找html元素

function getByClass(oparent, oclass){

var aEle = oparent.getElementsByTagName("*");
var i = 0;
var aResult = [];
for(i=0; i if(aEle[i].className == oclass){
aResult.push(aEle[i]);
}
}
return aResult;

}

ps:以上的document也可以换成object,它是查找在自己的子系元素

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!