How to reset a form using jQuery with .reset() method

前端 未结 16 1195
清酒与你
清酒与你 2020-11-22 17:28

I had working code that could reset my form when I click on a reset button. However after my code is getting longer, I realize that it doesn\'t work anymore.



        
16条回答
  •  逝去的感伤
    2020-11-22 18:01

    A reset button doesn't need any script at all (or name or id):

    
    

    and you're done. But if you really must use script, note that every form control has a form property that references the form it's in, so you could do:

    
    

    But a reset button is a far better choice.

提交回复
热议问题