Html 如何制作显示图像的按钮

Html 如何制作显示图像的按钮,html,image,button,Html,Image,Button,我想制作一个按钮,当用户单击该按钮时,它将显示一个图像,我希望它用于HTML: 显示图像如果我理解您的问题,您希望仅在用户单击按钮时向用户显示图像 这在JavaScript中是可能的: <html> <body> <img src="/path/to_img" style="display:none" id="myImage"/> <button type="button" onclick="myImage.style.display='block'

我想制作一个按钮,当用户单击该按钮时,它将显示一个图像,我希望它用于HTML:


显示图像

如果我理解您的问题,您希望仅在用户单击按钮时向用户显示图像

这在JavaScript中是可能的:

<html>

<body>
<img src="/path/to_img" style="display:none" id="myImage"/>
<button type="button" onclick="myImage.style.display='block';">Click me</button>
</body>
</html>

点击我

谢谢你,丹尼尔。是的,正是我想要的!你知道我是否可以为用户点击按钮后显示的图像设置特定尺寸吗?你可以通过css设置尺寸:宽度:100px;高度:120px;。