$.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属性
我需要动态设置selectedIndex属性值,以便更早地显示保存的值。我将在上面的代码中插入该代码到// code for access "selectedindex"
的地方。那么我怎样才能为dropdownList
设置selectedIndex属性?
你想设置或获取selectedIndex? – 2013-03-12 11:23:22
@Olylyodgson设置selectedIndex。 – Sampath 2013-03-12 11:24:08