DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> 下拉框select的綁定示例
下拉框select的綁定示例
編輯:關於JavaScript     

根據文本綁定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; 
} 
}

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved