js setattribute批量設置css樣式
更新時間:2009年11月26日 18:40:13 作者:
setattribute批量設置css樣式的實現代碼。
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開發(fā)的事實標準。因此測試顯示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開發(fā)的事實標準。因此測試顯示firefox瀏覽器也支持這種方式。
您可能感興趣的文章:
- javascript中setAttribute()函數使用方法及兼容性
- js中的getAttribute方法使用示例
- javascript中attribute和property的區(qū)別詳解
- JavaScript中setAttribute用法介紹
- JS getAttribute和setAttribute(取得和設置屬性)的使用介紹
- JavaScript中的property和attribute介紹
- javascript setAttribute, getAttribute 在不同瀏覽器上的不同表現
- Jquery attr()方法 屬性賦值和屬性獲取詳解
- jQuery使用attr()方法同時設置多個屬性值用法實例
- jQuery使用元素屬性attr賦值詳解
- JavaScript中的 attribute 和 jQuery中的 attr 方法淺析
相關文章
JavaScrpt中如何使用 cookie 設置查看與刪除功能
這篇文章主要介紹了JavaScrpt中使用 cookie 設置查看與刪除功能的方法,文中通過實例代碼給大家介紹了js cookie常用的3個預設函數庫,需要的朋友可以參考下2017-07-07Javascript oop設計模式 面向對象編程簡單實例介紹
這篇文章主要介紹了Javascript oop設計模式 面向對象編程簡單實例介紹的相關資料,這里附有實例代碼幫助大家學習理解,需要的朋友可以參考下2016-12-12