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>

 

posted @ 2018-10-18 09:55  就俗人一个  阅读(207)  评论(0)    收藏  举报