How to set the default value of a select box using JQuery in IE9?

跟風遠走 提交于 2019-11-30 13:02:17
DavidGouge

Instead of setting the selected attribute, just use .val("2").

See here: jsFiddle

Anyway, this worked well on IE9 if you want to mantain the "SELECTED" attribute

$("select#selId").find("option#2").attr("selected", true);

http://jsfiddle.net/cqENs/

andyb

You could use val() to set the option instead - see Change the selected value of a drop-down list with jQuery

change this one

$("select#selId").find("option#2").attr("selected", "selected");

into this one

$("select#selId").find("option#2").attr("selected", true); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!