[英]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.