修改css的API

  |  
 阅读次数

cssText的应用

1
2
3
4
5
// 重写
cssText = '';

// 累加
cssText += '';
1
2
3
4
5
6
7
/** 
* Element: DOM 元素
* 切换元素的 className
* 判断是否存在
*/
Element.classList.toggle('pause');
if (Element.classList.contains('pause')) {}
1
2
3
4
/** 兼容写法 */
navContainer.currentStyle // IE
? navContainer.currentStyle
: document.defaultView.getComputedStyle(navContainer, null)