有谁知道如何将背景图像放入文本框内?我想做的是,当我单击文本框时,它会用图像更改背景。有人知道该怎么做吗?
我当前的代码无法工作:
<input onfocus="this.style.background='images/activebutton.png'" />
CSS 是首选 method
CSS
<style>
input[type="text"]:focus{
background-image: url('images/activebutton.png');
}
</style>
HTML
<input type="text" />
如果你仍然想使用 JavaScript,你需要这样做
<input type="text"
onfocus="this.style.backgroundImage='url(images/activebutton.png)';"
onblur="this.style.backgroundImage=''"
/>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)