I have a simple select2:
<select id="material" class="form-control select2 select2-hidden-accessible" style="width: 100%;" aria-hidden="true">
<option value="1">PC</option>
<option value="2">Raton</option>
<option value="3">Teclado</option>
<option value="4">Monitor</option>
</select>
Your statement:
$('#material').select2();
The component works as expected.
The problem is that I change its value by:
$("#material").val("3");
And I check that its value changes with alert($("#material").val());
but it still shows the previous value.
That is, it does not update the component, how to solve this?
You should add after changing the
value
, achange()
so that the value changes are visually affected in the Dropdown.either