Style cssText 属性

Style 对象参考手册 Style 对象

定义和用法

cssText 属性设置或返回作为字符串的样式声明的内容。

语法

设置 cssText 属性:

Object.style.cssText="string"

返回 cssText 属性:

Object.style.cssText

描述
string规定样式声明的内容。


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 cssText 属性。


实例

实例

获取作为字符串的样式声明:

<html>
<head>
<script>
function displayResult()
{
alert(document.getElementById("p1").style.cssText);
}
</script>
</head>
<body>

<p id="p1" style="border:2px dashed green;color:red;">This is a paragraph.</p>
<br>
<button type="button" onclick="displayResult()">Get style declaration</button>

</body>
</html>

尝试一下 »


Style 对象参考手册 Style 对象

0 个评论

要回复文章请先登录注册