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

前端 未结 21 735
一个人的身影
一个人的身影 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:24

    If you are using chosen, a jquery plugin, then to refresh or clear the content of the dropdown use:

    $('#dropdown_id').empty().append($('< option>'))
    
    dropdown_id.chosen().trigger("chosen:updated")
    

    chosen:updated event will re-build itself based on the updated content.

提交回复
热议问题