注意标签的属性

标签的属性涉及三个方法,这三个方法分别是:

attributes:获取所有标签属性。

setAttribute(key,value):设置标签属性

getAttribute(key):获取指定标签属性

注意通过setAttribute()、getAttribute()就可以对标签进行操作了。

i1=document.getElementById('i1');

divs=i1.children;

for(var i=0;i<divs.length;i++)

{

current_div=divs[i]

var results= current_div.getAttribute('alex')

if results=="sb"{

current_div.innerText="456"

}

}

posted @ 2017-03-11 19:41  关泉珍  阅读(34)  评论(0)    收藏  举报