使用.添加属性和使用setattribute的区别
div id="ht">HTML5div>span id="html4">HTML4span>script>var sp = document.getElementsByTagName("span")[0];sp.id = "html5";console.dir(sp);var ht = document.getElementById("ht");ht.index =