How to add option to select list in jQuery

后端 未结 9 2208
迷失自我
迷失自我 2020-12-08 18:27

My select list is called dropListBuilding. The following code does not seem to work:

 for (var i = 0; i < buildings.length; i++) {
     var v         


        
9条回答
  •  孤城傲影
    2020-12-08 18:49

    It looks like you want this pluging as it follows your existing code, maybe the plug in js file got left out somewhere.

    http://www.texotela.co.uk/code/jquery/select/

    var myOptions = {
    "Value 1" : "Text 1",
    "Value 2" : "Text 2",
    "Value 3" : "Text 3"
    } 
    $("#myselect2").addOption(myOptions, false); 
    // use true if you want to select the added options » Run
    

提交回复
热议问题