Sample code for traversing element attributes within a DOM object_javascript skills
- WBOYOriginal
- 2016-05-16 17:01:101040browse
Directly enter the code:
For example, to get all the attributes of a button with the id "btn"
function showBtn()
{
var tmp="";
var objBtn = document.getElementById("btn");
for(var i in objBtn)
{
tmp = i ":" objBtn[i];
}
alert(tmp);
}
Statement: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