2012-10-03 27 views
-2

我有以下输入按钮代码。发生提交后,如何修改此代码以使用名为btn_nxt.png_hold.gif的按钮的灰色版本?onSubmit javascript窗体事件换出图像?

<input onsubmit="this.disabled=true;return true;" type="image" name="Insert" id="Insert" value="Insert" alt="Insert" src="images/btn_nxt.png" /> 
+2

代码在哪? –

+0

onsubmit =“this.disabled = true; return true;” –

+0

@ShadowWizard这是不正确的,我没有直接思考,当我发现它已经回答了这个问题,所以我删除它:) –

回答

4

您需要更改的图片单击该按钮时:

onclick="this.src='images/btn_nxt.png_hold.gif';" 

onsubmit只属于表单元素。

+0

我已经有一个onclick事件...是否有另一个事件,我可以使用onClick后发生火灾? –

+0

@Rocco不需要另一个事件,只需将'this.src = ...'添加到现有的'onclick'事件。 –

2
onclick="this.src='images/btn_nxt.png_hold.gif';this.disabled=true;" 
0

propper解决方案是在提交时向按钮添加一个类。使用样式表,您可以对您喜欢的按钮进行任何修改。

0

你也可以用jQuery来操纵它。它更干净。

$("#Insert").live("click", function(){ 

    $(this).attr("src","path/tp/image.gif").attr("disabled", "disabled"); 

}); 

希望它有帮助。