dropdown list 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);
}
精彩评论