x
 
<!DOCTYPE html>
<html>
<head>
<link id="myLink" rel="stylesheet" type="text/css" href="/demo/htmldom/style.css">
</head>
<body>
<h1>我使用链接的样式表进行格式化</h1>
<p>单击该按钮可更改链接文档的 href 属性的值。这将更换新的样式表。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
  document.getElementById("myLink").href = "/demo/htmldom/style_2.css";
}
</script>
</body>
</html>