zl程序教程

您现在的位置是:首页 >  前端

当前栏目

jQuery选中select控件无法设置selected的解决方法

jQuery方法 解决 设置 无法 控件 SELECT 选中
2023-06-13 09:14:24 时间
解决办法:把选中option的语句放到setTimeout中,例:
复制代码代码如下:

setTimeout(function(){
varselSorts=$("select[id^=""+controls.selsort+""]");
$.each(selSorts,function(index,sort){
varope=$(sort).find("option[value=""+arrSort[index]+""]");
if(ope.length>0)
ope[0].selected=true;
});
},1);