jQuery Chosen plugin add options dynamically

后端 未结 5 1633
闹比i
闹比i 2020-12-03 00:38

I make a jQuery Chosen drop-down like this:

$(\'.blah\').chosen();

I can\'t find how I can add options, something like:

5条回答
  •  忘掉有多难
    2020-12-03 01:01

    newest chosen version changed the event name to "chosen:updated"

    so your code will be like this:

    $('.blah').append("");
    $('.blah').val(key); // if you want it to be automatically selected
    $('.blah').trigger("chosen:updated");
    

提交回复
热议问题