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

后端 未结 4 1393
清歌不尽
清歌不尽 2021-01-02 08:07

I have the following select box.


                        
    
提交评论

  • 2021-01-02 08:51

    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/

    0 讨论(0)
  • 2021-01-02 08:55

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

    0 讨论(0)
  • 2021-01-02 08:56

    change this one

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

    into this one

    $("select#selId").find("option#2").attr("selected", true); 
    
    0 讨论(0)
  • 提交回复
    热议问题