Home  >  Article  >  Web Front-end  >  jquery select动态加载选择(兼容各种浏览器)_jquery

jquery select动态加载选择(兼容各种浏览器)_jquery

WBOY
WBOYOriginal
2016-05-16 17:42:231145browse

在ie6以上,我们可以通过
$("#selectID").val("xx");来个一个select控件赋值。但是在ie6下面会报错!!我们可以通过I下面方法来,使用方法:set_select_val($("#selectID" ),xx);//因为ie6不支持$("#" + provinceDom).attr("value", provinceDefvalue);

复制代码 代码如下:

function set_select_val(sel, val) {
if ($.browser.msie && $.browser.version == "6.0") {
setTimeout(function () {
sel.val(val);
}, 1);
} else {
sel.val(val);
}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn