简体   繁体   English

Javascript更改图像形式提交按钮src不起作用

[英]Javascript to change image form submit button src not working

I'm trying to change the src of an image form submit button using an onclick, but it doesn't seem to be working correctly. 我正在尝试使用onclick更改图像表单提交按钮的src,但它似乎无法正常工作。 Am I missing something? 我想念什么吗?

<input class="submit_image" id="my_form_button" onclick="$('my_form_button').src='/images/buttons/submitting.gif'" src="/images/buttons/submit.gif" type="image" /> 

I've also tried using the same JS on the form tag using onsubmit with no luck. 我也尝试过使用onsubmit在表单标签上使用相同的JS,但运气不佳。

onclick="this.src='/images/buttons/submitting.gif';"

Perhaps it's an illusion and your form is submitting and refreshing the page before it changes. 也许这是一种幻想,您的表单正在提交并刷新页面,然后才进行更改。 Try adding a return false ; 尝试添加return false ; to the end of your onclick statement? 到您的onclick语句的末尾?

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

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