課程
/前端開發
/JavaScript
/JavaScript入門篇
var cssText = document.getElementById('id').style.cssText;
獲得元素所有樣式,返回一個字符串;清空所有樣式只要將cssText賦值為空串即可。
2014-11-17
源自:JavaScript入門篇
正在回答
function getSetyle(div,styleName){
if (div.currentStyle) {
return div.currentStyle[styleName];
}else{
return getComputedStyle(div,null)[styleName];
}
舉報
JavaScript做為一名Web工程師的必備技術,本教程讓您快速入門
2 回答js獲取前面的所有兄弟元素 急求
1 回答js獲取元素和偽元素有什么區別?
3 回答JS通過ID獲取元素
4 回答獲取元素的寫法
2 回答關于獲取元素
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-05-20
function getSetyle(div,styleName){
if (div.currentStyle) {
return div.currentStyle[styleName];
}else{
return getComputedStyle(div,null)[styleName];
}
}