首页
Profile
Profile
Profile
Profile
Profile

获取元素的属性

2016-01-06 阅读 261
getAttribute是一个函数。它只有一个参数--你打算查询的属性的名字: ```html ``` 与普通方法不同,getAttribute 方法不属于document对象,所以不能通过document对象调用。它只能通过元素节点对象调用。例如,可以与`getElementsByTagName` 方法合用,获取每个<p>元素title属性: ```javascript var paras = document.getElementsByTagName("p"); for(var i = 0; i < paras.length; i++){ document.write(paras[i].getAttribute("title")); } ```
更新于 2023年03月28日
 
陕ICP备13008705号-1 Chat Gpt Api