jsp代码
jquery代码
$("#typeId option").each(function(){
if($(this).val()=='${template.typeId}'){
$(this).attr('selected',true);
}
});
jquery中的${template.typeId}是页面加载时传过来的数据
${template.typeId}在不同的条件下可以有不同的传入方式,
比如html+jquery
其他代码都一样,你只需要ajax取得要用的值即可
比如jsp(freemarker)+jquery
和原文实例一样
jsp jquery 页面中select显示加载后的数据默认选中项