jsPro1\js动态修改整个html页面样式(换肤).html
复制代码 代码如下:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>动态修改页面样式</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>修改整个页面的样式</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;
}
复制代码 代码如下:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>动态修改页面样式</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>修改整个页面的样式</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;
}
标签:
动态修改,页面样式,换肤
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“js动态修改整个页面样式达到换肤效果”评论...