How to clear all input fields in bootstrap modal when clicking data-dismiss button?

后端 未结 10 809
情话喂你
情话喂你 2020-12-04 10:58

How to clear all input fields in a Bootstrap V3 modal when clicking the data-dismiss button?

10条回答
  •  攒了一身酷
    2020-12-04 11:09

    I did it in the following way.

    1. Give your form element (which is placed inside the modal) anID.
    2. Assign your data-dimiss an ID.
    3. Call the onclick method when data-dimiss is being clicked.
    4. Use the trigger() function on the form element. I am adding the code example with it.

       $(document).ready(function()
           {
          $('#mod_cls').on('click', function () {
        $('#Q_A').trigger("reset");
          console.log($('#Q_A'));
       })
        });
      

        
    

    Hope this will help others as I was struggling with it since a long time.

提交回复
热议问题