js setattribute批量设置css样式

时间:2009-11-26    点击:97   
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 showModalDialog 多层模态窗口实现页面提交及刷新的代码
JavaScript 闭包在封装函数时的简单分析
extJs 文本框后面加上说明文字+下拉列表选中值后触发事件
Javascript 复制数组实现代码
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved