jquery how to empty input field

后端 未结 7 1819
鱼传尺愫
鱼传尺愫 2020-11-30 20:11

I am in a mobile app and I use an input field in order user submit a number.

When I go back and return to the page that input field present the latest number input d

7条回答
  •  爱一瞬间的悲伤
    2020-11-30 21:11

    While submitting form use reset method on form. The reset() method resets the values of all elements in a form.

    $('#form-id')[0].reset();
    
    OR 
    
    document.getElementById("form-id").reset();
    

    https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset

    $("#submit-button").on("click", function(){
           //code here
           $('#form-id')[0].reset();
    });
    
    
    
    
    
    
    First name:

    Last name:


提交回复
热议问题