簡體   English   中英

按鈕顯示圖像的問題

[英]Issue with Button Revealing Image

我在使用按鈕顯示圖像時遇到問題; 當頁面加載時,圖像已經出現,無需單擊指定的按鈕。

我試過了:

<HTML>
<head>
<style> 

  body {
  background-image: url("a2_page_3.JPG");
  background-size: cover;
  background-attachment: fixed;
  margin: 0;
  padding: 0;
}
</style>
<script>
  function showImage() {
    document.getElementById("stipends").style.display="";
  }
</script>
</head>
<body>
  <img id="stipends" src="a2_page_3_1.PNG" style="diaplay:none;"/>
  <input type=button value="Produce Stipends" onclick="showImgage()"/>
</body>
</html>

提前感謝您的所有輸入!

你有 2 個拼寫錯誤:你的按鈕中的 showImgage( showImgage()應該是showImage()並且你的圖像中的diaplay:none應該是display: none

這是它與 jsut 的 2 個 chages 一起工作(並添加了一個貓圖像來代替你的圖像)

 <HTML> <head> <style> body { background-image: url("a2_page_3.JPG"); background-size: cover; background-attachment: fixed; margin: 0; padding: 0; } </style> <script> function showImage() { document.getElementById("stipends").style.display=""; } </script> </head> <body> <img id="stipends" src="https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fgetwallpapers.com%2Fwallpaper%2Ffull%2Ff%2F3%2Fa%2F807159-download-funny-cats-wallpapers-1920x1200-meizu.jpg&f=1&nofb=1" style="display:none;"/> <input type=button value="Produce Stipends" onclick="showImage()"/> </body> </html>

 function showImage() { document.getElementById("stipends").style.display=""; }
 <body> <img id="stipends" src="a2_page_3_1.PNG" style="display:none;"/> <input type=button value="Produce Stipends" onclick="showImage()"/> </body> </html>

除了顯示的拼寫錯誤,正如我評論的那樣,您在按鈕“onclick”語句中將 function showImage() 拼寫為“showImgage()”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM