按钮背景图像更改

时间:2015-10-05 23:24:55

标签: html

我正在尝试制作按钮的背景图片。我成功添加了此代码以使其正常工作

<input type=submit name="y" value="1" onclick="this.form.submit()" 
       title='press here if the Serial works' 
       style="background-color: black; border: 0px solid #900; 
              background: url(/ar/serials/images/work.png) repeat-x;
              width:100px; height:40px; margin-left: 50px;">

问题是,我可以在同一行添加任何其他代码来更改背景图片onmouseoveronmouseout吗?

提前谢谢

2 个答案:

答案 0 :(得分:1)

添加以下属性:

onmouseover="this.style.background='url(image1.jpg)';"
onmouseout="this.style.background='url(image2.jpg)';"

答案 1 :(得分:0)

有些事情:

(您需要用自己的图片网址替换)

&#13;
&#13;
<input type=submit name="y" value="1" onclick="this.form.submit()" title='press here if the Serial works' onmouseover="this.style.background='url(http://placehold.it/100x40/000000/ffffff?text=1)';" onmouseout="this.style.background='url(http://placehold.it/100x40/ffffff/000000?text=1)';"
style="background-color: black; border: 1px solid #900; 
              background: url(http://placehold.it/100x40/ffffff/000000?text=1) repeat-x;
              width:100px; height:40px; margin-left: 50px;">
&#13;
&#13;
&#13;