1. 程式人生 > >JS練習:顯示和隱藏

JS練習:顯示和隱藏

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <script>    
        function hideImg(){
            var img = document.getElementById("img");
            img.style.display = "none";
        }
        
        function
showImg(){ var img = document.getElementById("img"); img.style.display = "block"; } </script> </head> <body> <input type="button" value="顯示" onclick="showImg()" /> <input type="button" value="隱藏" onclick="hideImg()" /><
br> <img src="https://www.cnblogs.com/images/cnblogs_com/believepd/1348456/o_%e5%90%83%e7%93%9c%e7%be%a4%e4%bc%97.gif" id="img" /> </body> </html>