js setattribute批量设置css样式
作者:bea
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;bor
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浏览器也支持这种方式。
有用 |
无用
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 学习笔记 Black.Caffeine 09.11.28
- Ruffy javascript 学习笔记
- jquery 分页控件实现代码
- JS 动态获取节点代码innerHTML分析 [IE,FF]
- Aptana调试javascript图解教程
- jQuery chili图片远处放大插件
- document.body.scrollTop 值总为0的解决方法 比较常见的标准问题
- javascript 设置某DIV区域内的checkbox复选框
- Javascript 构造函数,公有,私有特权和静态成员定义方法
- javascript 新闻列表排序简单封装
- JavaScript Alert通用美化类
- js鼠标移动在title中显示图片的效果代码
- [原创]javascript代码在ie8里报错 document.getElementById(...) 为空或不是对象的解决方法
- javascript &&和||运算法的另类使用技巧
- JavaScript 字符串操作的几种常见方法
- javascript showModalDialog 多层模态窗口实现页面提交及刷新的代码
- JavaScript 闭包在封装函数时的简单分析
- extJs 文本框后面加上说明文字+下拉列表选中值后触发事件
- Javascript 复制数组实现代码