chrome中Js的setAttribute支持不好?

时间:2014-03-12 15:39:09   收藏:0   阅读:427

  今天做页面用了这个函数

如果你这样

document.getElementById("a").sn = "111";
alert(document.getElementById("a").sn);

肯定全部浏览器都没问题

但是如果你

document.getElementById("a").setAttribute("sn","111");

alert(document.getElementById("a").sn);

这样却不行  尽管在chrome的开发者工具里面  已经看到动态的属性生成了   <div id="a" sn="111"></div>

总结:

chrome里面    如果你setAttribute  那么只能通过getAttribute访问   反过来 如果你是$("a").sn="111",这种用点号赋值的方法  也只能通过点号访问

IE里面随意   

chrome中Js的setAttribute支持不好?,布布扣,bubuko.com

原文:http://www.cnblogs.com/whx20202/p/3596105.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!