<html>
<head>
<style>
body {
background-color: yellow;
color: red;
}
</style>
</head>
<body>
<p>单击按钮可显示该文档的 style 属性。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementsByTagName("STYLE")[0];
document.getElementById("demo").innerHTML = x.innerHTML;
}
</script>
</body>
</html>