javascript 改變網頁載入的CSS

來源:互聯網
上載者:User

這個是沒有種cookie的,記錄給自已。 複製代碼 代碼如下:<link href="001.css" id="cssfile" rel="stylesheet" type="text/css" />
<script>
function changeStyle(name){
//alert(name);
var css = document.getElementById("cssfile");
css.href = name+".css";
}
</script>

複製代碼 代碼如下:<select onchange="changeStyle(this.options[this.selectedIndex].value)">
<option value="001" selected="selected">預設樣式</option>
<option value="blue">藍色經典</option>
<option value="red">紅色夢幻</option>
</select>
<div id="cssTest">
我是一隻小小小小小鳥!
</div>

看一下效果 xmlns="http://www.w3.org/1999/xhtml">


預設樣式藍色經典紅色夢幻我是一隻小小小小小鳥!

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.