js動(dòng)態(tài)修改整個(gè)頁(yè)面樣式達(dá)到換膚效果
更新時(shí)間:2014年05月23日 09:54:07 作者:
這篇文章主要介紹了通過(guò)js動(dòng)態(tài)修改整個(gè)頁(yè)面樣式達(dá)到換膚效果,需要的朋友可以參考下
jsPro1\js動(dòng)態(tài)修改整個(gè)html頁(yè)面樣式(換膚).html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>動(dòng)態(tài)修改頁(yè)面樣式</title>
<link href="css/blue.css" rel="stylesheet" id="mylink"/>
<script type="text/javascript">
function gel(id) {
return document.getElementById(id);
}
window.onload = function() {
//更換css文件
var lis = gel("uList").childNodes;
for (var i = 0; i < lis.length; i++) {
if (lis[i].nodeType == 1) {
lis[i].onclick = function () {
gel("mylink").href = "css/" + this.className + ".css";
};
}
}
};
</script>
</head>
<body>
<div>
<span>修改整個(gè)頁(yè)面的樣式</span><br/>
<input type="text" id="txt"/>
<input type="button" value="提交" class="btn"/>
</div>
<ul id="uList" style="text-decoration: none;margin-top: 100px;">
<li style="display: block;width: 30px;height: 20px;background-color: red;" class="red"></li>
<li style="display: block;width: 30px;height: 20px;background-color: blue" class="blue"></li>
</ul>
</body>
</html>
jsPro1\css\red.css
* {
margin: 0px;padding: 0px;
}
body {
background-color: #eeeeee;
}
span {
color: red;
}
#txt {
color: #f00;border: 1px solid #7d1515;
}
.btn {
background-color: #a52a2a;border: none;color: white;width: 100px;height: 28px;
}
jsPro1\css\blue.css
* {
margin: 0px;padding: 0px;
}
body {
background-color: #eeeeee;
}
span {
color: blue;
}
#txt {
color: #0000cd;border: 1px solid #006400;
}
.btn {
background-color: #0000cd;border: none;color: white;width: 100px;height: 28px;
}
復(fù)制代碼 代碼如下:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>動(dòng)態(tài)修改頁(yè)面樣式</title>
<link href="css/blue.css" rel="stylesheet" id="mylink"/>
<script type="text/javascript">
function gel(id) {
return document.getElementById(id);
}
window.onload = function() {
//更換css文件
var lis = gel("uList").childNodes;
for (var i = 0; i < lis.length; i++) {
if (lis[i].nodeType == 1) {
lis[i].onclick = function () {
gel("mylink").href = "css/" + this.className + ".css";
};
}
}
};
</script>
</head>
<body>
<div>
<span>修改整個(gè)頁(yè)面的樣式</span><br/>
<input type="text" id="txt"/>
<input type="button" value="提交" class="btn"/>
</div>
<ul id="uList" style="text-decoration: none;margin-top: 100px;">
<li style="display: block;width: 30px;height: 20px;background-color: red;" class="red"></li>
<li style="display: block;width: 30px;height: 20px;background-color: blue" class="blue"></li>
</ul>
</body>
</html>
jsPro1\css\red.css
復(fù)制代碼 代碼如下:
* {
margin: 0px;padding: 0px;
}
body {
background-color: #eeeeee;
}
span {
color: red;
}
#txt {
color: #f00;border: 1px solid #7d1515;
}
.btn {
background-color: #a52a2a;border: none;color: white;width: 100px;height: 28px;
}
jsPro1\css\blue.css
復(fù)制代碼 代碼如下:
* {
margin: 0px;padding: 0px;
}
body {
background-color: #eeeeee;
}
span {
color: blue;
}
#txt {
color: #0000cd;border: 1px solid #006400;
}
.btn {
background-color: #0000cd;border: none;color: white;width: 100px;height: 28px;
}
相關(guān)文章
如何在JavaScript中等分?jǐn)?shù)組的實(shí)現(xiàn)
這篇文章主要介紹了如何在JavaScript中等分?jǐn)?shù)組的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12php類(lèi)中static與self的使用區(qū)別淺析
在閱讀一些框架的源碼時(shí)發(fā)現(xiàn)了new static(),和new self(),甚是不解,后來(lái)查閱資料,才了解了,所以下面這篇文章主要給大家介紹了關(guān)于php類(lèi)中static與self的使用區(qū)別的相關(guān)資料,需要的朋友可以參考下2021-06-06原生js如何實(shí)現(xiàn)call,apply以及bind
這篇文章主要介紹了原生js實(shí)現(xiàn)call,apply以及bind,幫助大家更好的理解和學(xué)習(xí)使用JavaScript,感興趣的朋友可以了解下2021-04-04javascript vvorld 在線(xiàn)加密破解方法
朋友公司開(kāi)發(fā)的在線(xiàn)JS加密站點(diǎn),內(nèi)測(cè)中,自己試過(guò)不能找到加密后的源代碼,不知道還有那位大大能夠破解2008-11-11Firefox中beforeunload事件的實(shí)現(xiàn)缺陷淺析
beforeunload 指在頁(yè)面卸載前提供的最后一次JS執(zhí)行的機(jī)會(huì)2012-05-05使用Firebug對(duì)js進(jìn)行斷點(diǎn)調(diào)試的圖文方法
使用Firebug調(diào)試JavaScript非常方便。因?yàn)閖s的錯(cuò)誤不容易查找,用這個(gè)就方便多了。2011-04-04微信小程序判斷手機(jī)號(hào)是否合法的實(shí)例代碼
我們?cè)谖⑿判〕绦蜷_(kāi)發(fā)的時(shí)候,手機(jī)號(hào)的驗(yàn)證是經(jīng)常需要操作的,那么如何驗(yàn)證手機(jī)號(hào)呢?這篇文章主要給大家介紹了關(guān)于微信小程序判斷手機(jī)號(hào)是否合法的相關(guān)資料,需要的朋友可以參考下2021-09-09