頁面動態更改樣式方法

<html>
 <head>
 <title> new document </title>
 <link rel="stylesheet" type="text/css" href="report.css" id="ReportCss"/>
 <script>
  function switchToCss()
  {
   document.getElementById('ReportCss').href = "report-2px.css";
  }
 </script>
 </head>
<body>
<input type="button" value="改變風格" onclick="switchToCss()">

</body>

</html>

開始使用一個css樣式,然後通過修改href使用另外的樣式文件

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章