Posted in Javascript onSeptember 04, 2014
根据文本绑定text
var locationCity = productViewObj.Product.LocationCity; var countCity = $("#slCity option").length; for (var i = 0; i < countCity; i++) { if ($("#slCity").get(0).options[i].text == locationCity) { $("#slCity").get(0).options[i].selected = true; break; } }
根据值绑定value
var deliveryTemplateID = productViewObj.Product.DeliveryTemplateID; var deliveryCount = $("#deliverySelect option").length; for (var i = 0; i < deliveryCount; i++) { if ($("#deliverySelect").get(0).options[i].value == deliveryTemplateID) { $("#deliverySelect").get(0).options[i].selected = true; break; } }
下拉框select的绑定示例
- Author -
whsnow声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@