How can I reset a form with jQuery chosen plugin?

后端 未结 10 1316
甜味超标
甜味超标 2020-12-04 15:12

I have a bunch of select elements in a form with which I am using the Jquery Chosen plugin. How can I reset the form? The following does not work:



        
10条回答
  •  一向
    一向 (楼主)
    2020-12-04 15:46

    in order to have reset working naturally use this:

    $("input[type='reset'], button[type='reset']").click(function(e){
        e.preventDefault();
    
        var form = $(this).closest('form').get(0);
        form.reset();
    
        $(form).find('select').each(function(i, v) {
            $(v).trigger('chosen:updated');
        });
    }
    

提交回复
热议问题