zoukankan      html  css  js  c++  java
  • css 用js替换

    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;}







  • 相关阅读:
    很难理解的三个设计模式
    设计模式思考(转)
    AOP
    CAP理论(摘)
    DDBS
    NoSql
    Enterprise Library 企业库
    padright padleft
    Process ProcessThread Thread
    053374
  • 原文地址:https://www.cnblogs.com/chengyalin/p/11236487.html
Copyright © 2011-2022 走看看