如何制作一个内联的 css,点击后会改变输入按钮的颜色或图像?
<div><input type="button" id="btn" style="background-image:url('old.png');width:36px;height:36px;" onclick="change();"></div>
function change() {
document.getElementById("btn").style.backgroundImage=url('new.png');
}
如何用 JavaScript 完成这个?我错过了一些东西......
或者是否有更简单的 html 或 css 解决方案?
最佳答案
<input type="button" id="btn" style="background-color:green;width:36px;height:36px;" onclick="change();">
关于javascript - 从内联 css 和 JavaScript 按钮图像的点击更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23020890/