jsp页面:
<select id="TFTypeID" name="TFTypeID" >
<option value="1" >微信零钱</option>
<option value="2" >银行卡</option>
<option value="3" >支付宝</option>
</select>
js实现方式:
$(function(){
var count = $("#TFTypeID option").length;
var tf = ${pd.TFTYPEID};//后端传值
for (var i = 0; i < count; i++) {
if ($("#TFTypeID ").get(0).options[i].value ==tf) {//获取select 的value值和入参比较
$("#TFTypeID ").get(0).options[i].selected = true;
break;
}
if ($("#TFTypeID ").get(0).options[i].value ==tf ) {
$("#TFTypeID ").get(0).options[i].selected = true;
break;
}
if ($("#TFTypeID ").get(0).options[i].value == tf) {
$("#TFTypeID ").get(0).options[i].selected = true;
break;
}
}
})