html 如下
<!doctype html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link href="1.css" rel="stylesheet" type="text/css" id="css"> <title>Document</title></head><body><a href="#" onClick="change(1)">1.css 点击变白</a><a href="#" onClick="change(2)">2.css 点击变黑</a><script type="text/javascript"> function change(a){ var css=document.getElementById("css"); if (a==1) css.setAttribute("href","1.css"); if (a==2) css.setAttribute("href","2.css"); }</script></body></html>1css如下
body{background-color: #fff;color: #333;}
2css如下
body{background-color: red;color: #333;}
来源:https://www.cnblogs.com/chengyalin/p/11236487.html