JS属性节点
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
/*
attributes 获取当前元素节点上的所有的属性节点
*/
window.onload = function(){
var oDiv = document.getElementById("div1");
//获取其中的某一个属性节点
//title = hello
alert(oDiv.attributes["title"].nodeName);// title
alert(oDiv.attributes["title"].nodeType);// 2
alert(oDiv.attributes["title"].nodeValue);// hello
}
</script>
</head>
<body>
<div id="div1" title="hello" class="box">div文本</div>
</body>
</html>