开发者

Javascript mouseover event to change form submit button image

开发者 https://www.devze.com 2023-02-07 12:54 出处:网络
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.Here is

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. 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:

...

    <a href="#" onMouseOver=&q开发者_C百科uot;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?


either use :hover CSS property or jQuery's $.hover() function to achieve this.

0

精彩评论

暂无评论...
验证码 换一张
取 消