Null Reference Null Reference - 1 year ago 88
HTML Question

Bootstrap: select/option list doesn't get refreshed after programmatically adding item

I have the following select/option

<select class="bs-select form-control">
<option value="AL">Alabama</option>
<option value="WY">Wyoming</option>

In my script section, I have this, which works fine. The styles are being applied

$(document).ready(function () {

I have a button that does this:

$('.bs-select').append($('<option>', {
value: 0,
text: "test"

However my select list isn't refreshed.

I tried adding


after the append but it still doesn't work.

My select list gets refreshed if I remove the

How can I get my list to refresh after adding an item?

Answer Source

Use refresh after adding new option

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download