给下拉列表添加options

var myOptions = {
    val1 : 'text1',
    val2 : 'text2'
};
var mySelect = $('#mySelect');
$.each(myOptions, function(val, text) {
    mySelect.append(
        $('<option></option>').val(val).html(text)
    );
});

 

posted @ 2016-11-08 14:34  Chris_在IT道路上前行  阅读(158)  评论(0编辑  收藏  举报