Populate dropdown select with array using jQuery

后端 未结 8 1908
花落未央
花落未央 2020-11-29 08:07

I am trying to populate a dropdown select with an array using jQuery.

Here is my code:

        // Add the list of numbers to the drop down here
              


        
8条回答
  •  情书的邮戳
    2020-11-29 08:39

    Since I cannot add this as a comment, I will leave it here for anyone who finds backticks to be easier to read. Its basically @Reigel answer but with backticks

    var numbers = [1, 2, 3, 4, 5];
    var option = ``;
    for (var i=0;i${numbers[i]}`;
    }
    $('#items').append(option);
    

提交回复
热议问题