jQuery选中select控件 无法设置selected的解决方法
更新时间:2010年09月01日 00:07:34 作者:
select 控件的 option用jQuery动态添加,然后选中某项时,IE6不能执行(火狐没问题),用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#软件开发中的GridView控件,需要的朋友可以参考下2015-12-12
最新评论