1、绑定属性:
(1)元素节点.属性或元素节点[属性]绑定的属性不会出现在标签中,setAttribute可以出现在标签中。
(2)setAttribute获取不到元素节点.属性形式绑定的属性值,同样元素节点.属性也获取不到setAttribute绑定的属性值
<body> ???<div id="box"></div> ???<script> ???????var box = document.getElementById("box"); ???????box.add = "add"; ???????console.log(box.add);//add ???????box.setAttribute("yes", "yes"); ???????console.log(box.getAttribute("yes"));//yes ???????console.log(box.yes);//undefined ???????console.log(box.getAttribute("add"));//null ???</script></body>
JS——特殊情况
原文地址:http://www.cnblogs.com/wuqiuxue/p/7874586.html