简体   繁体   English

Javascript mouseover事件以更改表单提交按钮图像

[英]Javascript mouseover event to change form submit button image

I am attempting to dynamically change the "src" attribute of a form submit button via javascript by containing the form element within a link in order to capture the mouseover event. 我试图通过在链接中包含form元素来通过javascript动态更改表单提交按钮的“ src”属性,以捕获mouseover事件。 Here is my code: 这是我的代码:

<SCRIPT language="JavaScript">
  paypal_img_mouse_over = new Image(120,120); 
  paypal_img = new Image(120,120); 
  paypal_img_mouse_over.src="Paypal_Button_Mouseover.png"; 
  paypal_img.src="Paypal_Button.png"; 

function Paypal_Mouse_Over()
{
  document.Paypal_Button.src=paypal_img_mouse_over.src;
}
function Paypal_Mouse_Out()
{
  document.Paypal_Button.src=paypal_img.src;
} 
</script>

... ...

And later on, the form element: 然后是form元素:

... ...

    <a href="#" onMouseOver="Paypal_Mouse_Over()" onMouseOut="Paypal_Mouse_Out()">
        <input type="image" src="Paypal_Button.png" name="Paypal_Button" id="Paypal_Button" value=" Continue ">
    </a>
</form>

Should this method be working as rollover effect for my form submit image? 这种方法是否可以作为我的表单提交图像的翻转效果?

Thanks in advance. 提前致谢。

使用:hover CSS属性或jQuery的$ .hover()函数即可实现此目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM