jQuery实现动态选中select

// jquery实现动态选中select

var active = $('.all_sla_title1 .active')
var group_name = active.html();
var sla = active.attr('data-sla');
var remote = active.attr('data-remote');
 // console.log(group_name + sla + remote);
$.each($('#sla option'), function(i, n) {
    if ($(n).val() == sla) {
        $(n).attr("selected", true);
    }
});

 

posted @ 2017-03-31 19:40  gentsir  阅读(3967)  评论(0编辑  收藏  举报