1、绑定自定义属性:
(1)元素节点.属性或元素节点[属性]绑定的属性不会出现在标签中,setAttribute可以出现在标签中。
(2)setAttribute获取不到元素节点.属性形式绑定的属性值,同样元素节点.属性也获取不到setAttribute绑定的属性值
2、绑定内部规定属性:
(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>