网站换肤cssjs

xiaoxiao2025-07-13  11

<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选择

转载请注明原文地址: https://www.6miu.com/read-5033028.html

最新回复(0)