jQuery Chosen plugin add options dynamically

后端 未结 5 1631
闹比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:12

    I used below code to update choosen dropdown options dynamically and it works:

    var myDropDownOptionHtml =''; 
    
    $('#myDropdownId').html(myDropDownOptionHtml );
    setTimeout(function() {
        $("#myDropdownId").trigger("liszt:updated");
    },100);
    

    FYI, I am using jQuery Chosen Version 0.13.0

    Happy Coding!

提交回复
热议问题