jQuery: A problem with .each function
I send t开发者_开发技巧o the javascript an array like:
$.each(data, function (value, name) {
$('#visitStart').append($('<option></option>').val(value).html(value));
});
and as a result I see that the visitStart input is filled by values from 0 to 241. Why ?
$.each sends an index, and value into the callback function - http://api.jquery.com/jQuery.each/
$.each(data, function (i, obj) {
$('#visitStart').append($('<option></option>').val(obj.value).html(obj.value));
});
精彩评论