Adding options to a <select> using jQuery?

后端 未结 30 2159
萌比男神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

    That works well.

    If adding more than one option element, I'd recommend performing the append once as opposed to performing an append on each element.

提交回复
热议问题