<html>
<head>
<style>
#ex1 {
color: red;
}
</style>
</head>
<body>
<h1>getPropertyValue() 方法</h1>
<p>单击按钮可返回 color 属性的值。</p>
<button onclick="myFunction()">试一试</button>
<div id="ex1">一些文本。</div>
<script>
function myFunction() {
var declaration = document.styleSheets[0].cssRules[0].style;
var propvalue = declaration.getPropertyValue("color");
alert(propvalue);
}
</script>
</body>
</html>