开发者

dropdown list jquery

开发者 https://www.devze.com 2023-02-15 00:38 出处:网络
I have an array with the following value, [[\'6\'开发者_JAVA百科,\'Ltr\'],[\'7\',\'Ml\']] How can I use the array to fill a drop down list using jquery

I have an array with the following value,

[['6'开发者_JAVA百科,'Ltr'],['7','Ml']]

How can I use the array to fill a drop down list using jquery


  • DEMO 2: http://jsbin.com/ewimo4/2
$(function() {
    var arr = [['6', 'Ltr'], ['7', 'Ml']];
    var html = "<select>";
    $.each(arr,function(i, item) {
        html += '<option value="' + item[0] + '">' + item[1] + '</option>';
    });
    html += "</select>";
    $('#select').html(html);
});
  • DEMO : http://jsbin.com/ewimo4
$(function() {
    var arr = [['6', 'Ltr'], ['7', 'Ml']];
    $.each(arr,function(i, item) {
        alert(item[0] + ' ' + item[1]);
    });
});


Take a look at this.

var handles = [];

function populateHandles() {
   var options = '';
   for (var i = 0; i < handles.length; i++) {
      options += '<option value="' + handles[i] + '">' + handles[i] + '</option>';
   }
   $('#listBox').html(options);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消