首页 > 编程 > JavaScript > 正文

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

2019-11-21 00:16:15
字体:
来源:转载
供稿:网友
解决办法:把选中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);
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表