$.fn.fillSelect = function (data) {
return this.clearSelect().each(function () {
if (this.tagName == 'SELECT') {
var dropdownList = this;
$.each(data, function (index, optionData) {
var option = new Option(optionData.Text, optionData.Value);
if ($.browser.msie) {
dropdownList.add(option);
} else {
dropdownList.add(option, null);
}
});
// code for access "selectedindex"
}
});
};
上記は、jQuery を使用してドロップダウンを動的に生成するためのコード スニペットです。
保存された値を以前に表示するために、selectedIndexプロパティ値を動的に設定する必要があります。// code for access "selectedindex"
そのコードを上記のコード内に挿入します。では、 selectedIndexプロパティをどのように設定できdropdownList
ますか?