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

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

    The first option should sufice: http://jsfiddle.net/sFCg3/

    jQuery('#autoship_option').val('');
    

    But you have to make sure you are runing this on an event like click of a button or ready or document, like on the jsfiddle.

    Also make sure that theres always a value attribute on the option tags. If not, some browsers always return empty on val().

    Edit:
    Now that you have clarifyed the use of the Chosen plugin, you have to call

    $("#autoship_option").trigger("liszt:updated");
    

    after changing the value for it to update the intereface.

    http://harvesthq.github.com/chosen/

提交回复
热议问题