亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

JS控制DIV樣式

??? 2019-01-31 21:43:44 224
????:<!DOCTYPE html> <html>          <head>         <meta charset="UTF-8">  
<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>JS控制DIV樣式</title>
        <style>
</style>
    </head>
    
    <body>
        <div id="box"></div>
        <input type="button" value="變高" onclick="changeh(this)">
        <input type="button" value="變寬" onclick="changew(this)">
        <input type="button" value="變色" onclick="changec(this)">
        <input type="button" value="重置" onclick="reset(this)">
        <input type="button" value="隱藏" onclick="hide(this)">
        <input type="button" value="顯示" onclick="show(this)">
        <script>
            var box;
            window.onload = function() {
                box = document.getElementById("box");
            }

            function changeh() {
                box.style.height = "300px";
            }

            function changew() {
                box.style.width = "300px";
            }

            function changec() {
                box.style.background = "#000";
            }

            function reset() {
                box.style = "reset";
            }

            function hide() {
                box.style.display = "none";
            }

            function show() {
                box.style.display = "block";
            }
        </script>
    </body>

</html>

多多練習,重置樣式也可以使用reset。

?? ???:韋小寶?? ??:2019-02-01 09:39:05
???? ??:寫的很不錯 JavaScript不僅僅可以控制div的樣式 對dom的操作也很靈活

??? ??

?? ??