网站换肤css/js

<div>
    <button type="button" class="btn btn-blue" data-name="blue">蓝色</button>
    <button type="button" class="btn btn-orange" data-name="orange">橙色</button>
    <button type="button" class="btn btn-red" data-name="red">红色</button>
    <button type="button" class="btn btn-green" data-name="green">绿色</button>
</div>


<script>
    $(function(){
		$(".theme button").click(function()){
			var theme = $(this).attr("data-name");
			$("body").attr("class",theme);
		}
	});
</script>

css:

body.blue{background:blue;}
body.orange{background:orange;}
body.red{background:red;}
body.green{background:green;}

把改变颜色的部分设置多个class选择

猜你喜欢

转载自blog.csdn.net/LLL_liuhui/article/details/83379346