JS練習:顯示和隱藏
阿新 • • 發佈:2018-11-24
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script> function hideImg(){ var img = document.getElementById("img"); img.style.display = "none"; } functionshowImg(){ 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>