[英]Javascript/jQuery - Change input button the background image when mouse down and up
我想在鼠标按下和抬起时更改背景图像的输入按钮,但它不起作用。
function mousedown() { document.getElementById("enlarge_btn").style.backgroundImage = "url(../picture/image2.svg)"; } function mouseup() { document.getElementById("enlarge_btn").style.backgroundImage = "url(../picture/image1.svg)"; }
.button_img { width: 36px; height: 36px; background-image: url(../picture/image1.svg); background-color: transparent; background-size: cover; border: none; cursor: pointer; }
<input id="enlarge_btn" type="button" name="button" class="button_img" onmousedown="mousedown()" onmouseup="mouseup()">
我在哪里可以修复?
请帮帮我,谢谢!
我发现如果我改变
document.getElementById("enlarge_btn").style.backgroundImage = "url(../picture/image2.svg)";
到
document.getElementById("enlarge_btn").style.backgroundImage = "url(picture/image2.svg)";
它有效,所以问题是文件路径。
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.