根据已知值,选中selec中的选项

$("#modal").find("select[name=materialType]").find("option").each(function(){
        var val = $(this).attr("value");
        if(val==data.materialType){
        $(this).prop("selected",true);
        }
    });

 

简化版

 

$("#modal").find("select[name=materialType]").find("option[value="+ data.materialType +"]").prop("selected",true);

 

posted @ 2017-08-17 17:05  boyanh  阅读(205)  评论(0编辑  收藏  举报