jQuery選中select控件 無法設置selected的解決方法
更新時間:2010年09月01日 00:07:34 作者:
select 控件的 option用jQuery動態(tài)添加,然后選中某項時,IE6不能執(zhí)行(火狐沒問題),用try{}catch(err){alert(err.description);}提示為“無法設置selected屬性 未指明的錯誤”
解決辦法:把選中option的語句放到setTimeout中,例:
setTimeout(function() {
var selSorts = $("select[id^='" + controls.selsort + "']");
$.each(selSorts, function(index, sort) {
var ope = $(sort).find("option[value='" + arrSort[index] + "']");
if (ope.length > 0)
ope[0].selected = true;
});
}, 1);
復制代碼 代碼如下:
setTimeout(function() {
var selSorts = $("select[id^='" + controls.selsort + "']");
$.each(selSorts, function(index, sort) {
var ope = $(sort).find("option[value='" + arrSort[index] + "']");
if (ope.length > 0)
ope[0].selected = true;
});
}, 1);
相關文章
利用jQuery及AJAX技術定時更新GridView的某一列數據
這篇文章主要介紹了利用jQuery及AJAX技術定時更新GridView的某一列數據的方法,這里的GridView是指C#軟件開發(fā)中的GridView控件,需要的朋友可以參考下2015-12-12