How do I reset a jquery-chosen select option with jQuery?

前端 未结 21 761
一个人的身影
一个人的身影 2020-11-30 21:42

I have tried numerous things and nothing seems to be working.

I am using jQuery and Chosen plugin.

Methods I have tried:

var select = jQuery(         


        
21条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 22:18

    Exactly i had the same requirement. But resetting the drop down list by setting simply empty string with jquery won't work. You should also trigger update.

    Html:
    
    
    Jquery:
    $('.chosen-control').val('').trigger('liszt:updated');
    

    sometimes based on the version of chosen control you are using, you may need to use below syntax.

    $('.chosen-control').val('').trigger("chosen:updated");
    

    Reference: How to reset Jquery chosen select option

提交回复
热议问题