<!DOCTYPE html>
<html>
<head>
<title>点击换肤</title>
<meta charset="utf-8" />
<link id="skin" rel="stylesheet" type="text/css" href="02-purple.css">
</head>
<body>
<button onclick="toPink();">粉色</button>
<button onclick="toCyan();">青色</button>
</body>
<script>
function toPink()
{
//要改谁 就找到那个对象
document.getElementById('skin').href="02-pink.css";
}
function toCyan()
{
document.getElementById('skin').href="02-cyan.css";
}
</script>
</html>
附:简单的css代码:body {
background-color:purple;
}其他的css也是类似的。
本文介绍了一种通过JavaScript实现网页换肤的方法。用户可以通过点击按钮切换不同的CSS样式文件来改变网站的主题颜色。提供了两种主题样式:粉色和青色。
5559

被折叠的 条评论
为什么被折叠?



