Adding options to a <select> using jQuery?

后端 未结 30 1682
萌比男神i
萌比男神i 2020-11-22 03:56

What\'s the easiest way to add an option to a dropdown using jQuery?

Will this work?

$(\"#mySelect\").append(\'
30条回答
  •  礼貌的吻别
    2020-11-22 04:38

    for whatever reason doing $("#myselect").append(new Option("text", "text")); isn't working for me in IE7+

    I had to use $("#myselect").html("");

提交回复
热议问题