js setattribute批量设置css样式
js setattribute批量设置css样式
发布时间:2016-12-30 来源:查字典编辑
摘要:firefox等可以使用vardom=document.getElementById("name");dom.setAttribute("s...

firefox等可以使用

var dom=document.getElementById("name");

dom.setAttribute("style","width:10px;height:10px;border:solid 1px red;") ;

IE中则必须使用style.cssText

var dom=document.getElementById("name");

dom1.style.cssText = "width:10px;height:10px;border:solid 1px red;";

补充一下,目前style.cssText类似innerHTML了,已经成为一个web开发的事实标准。因此测试显示firefox浏览器也支持这种方式。

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类