【javascript】修改css href

<!DOCTYPE html>
<html>

<head>
    <link href="./.css" rel="stylesheet" type="text/css" id="css">
    <script>
        function change(color) {
            let css = document.getElementById("css")
            if (color == "red") css.setAttribute("href", "./red.css")
            if (color == "green") css.setAttribute("href", "./green.css")
        }
    </script>
</head>

<body>
    <h1>change css by js herf</h1>
    <p>this is the raido group</p>
    <div>
        <from>
            <input name="color" type="radio" onclick="change('red')" value="red">red</input>
            <input name="color" type="radio" onclick="change('green')" value="green">green</input>
        </from>
    </div>
</body>

</html>
body {
    color: red;
}

h1 {
    text-decoration-line: 1px;
}

div {
    background-color: rgb(224, 71, 84);
    border: 1px dotted rgb(255, 191, 191);
}

//green
body {
    color: green;
}

h1 {
    text-decoration-line: 1px;
}

div {
    background-color: darkgreen;
    border: 1px dotted palegreen;

【javascript】修改css href

 

 【javascript】修改css href

 

上一篇:OpenCV图像处理算法——11(IEEE Xplore 2015的图像白平衡处理之动态阈值法)


下一篇:算法 - 剪枝游戏 - Green Hackenbush