CSSStyleDeclaration cssText 属性
定义和用法
cssText
属性设置或返回元素的行内(内联)样式声明的值。
实例
例子 1
返回 h1 元素的行内样式的值:
var elmnt = document.getElementsByTagName("h1")[0]; var x = elmnt.style.cssText;
例子 2
设置元素行内样式声明的文本:
document.getElementById("ex1").style.cssText = "color: blue;";
语法
返回 cssText 属性:
element.style.cssText
Set cssText property:
element.style.cssText = style
Technical Details
DOM Version: | Level 2 Style CSS |
---|---|
Return Value: | String that represents the inline style of the specified element. |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |