信息发布→ 登录 注册 退出

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

发布时间:2026-01-11

点击量:
解决办法:把选中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  # ope  # index  # true  # selsort  # gt  # selected  # length  # find  # arrSort  # BR  # span  # jQuery  # controls  # option  # select  # id  # selSorts  # function  # var  # 解决办法  # 解决option标签selected="selected"属性失效的问题  # js给selected添加options的方法  # select控件  
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!