开发者

jQuery reset refreshing browser as well as resetting form

I am trying to issue a form reset to clear t开发者_Python百科he contents back to there initial state. What is happening however, is that the form clears but also the browser refreshes. I have also tried putting the code inside a document ready but still the same. Can someone explain to me why this is happening. Thanks

<button id="AUSR_reset" class="resetbutton icon-right ui-state-default2 ui-corner-all"><span class="ui-icon ui-icon-circle-plus"></span>Reset</button>

<script language="javascript" type="text/javascript">


            $("#AUSR_reset").click(function() {

               $("#AUSR_adduser").get(0).reset();

            });


In order to rest the form elements use a reset button within the form. It will reset all the form elements without any js help.

<input type="reset" value="Reset" />


Add type="button" to the button. Otherwise it acts as a submit button.

<button type="button" id="AUSR_reset" class="resetbutton icon-right ui-state-default2 ui-corner-all">
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜