function SetSelectOption(eleSelect, text, value) {
var tempValue = false;
if (eleSelect.options!= undefined && eleSelect.options.length > 1) {
var options = eleSelect.options;
for (var i = 0; i < options.length; i++) {
if (options[i].value == value) {
eleSelect.options[i].selected = true;
tempValue = true;
break;
}
}
if (!tempValue) {
eleSelect.options.add(new Option(text, value));
eleSelect.options[eleSelect.options.length-1].selected = true;
}
}
else {
eleSelect.options.add(new Option(text, value));
eleSelect.options[eleSelect.options.length - 1].selected = true
}
}
posted on 2011-09-13 14:21
王豪 阅读(466)
评论(0) 编辑 收藏 所属分类:
JQuery