Reputation: 151
I want to change the value from a drop-down list via jQuery.
<option value="Yes" data-select2-id="248">Yes</option>
In this instance I want to change the value="Yes"
to value="15"
.
Is there any way to do this?
Upvotes: 0
Views: 46
Reputation: 151
This is what I did with the select2 plugin.
It finds the text of the option and changes the vaule.
$('#Contact').find("option:contains(" + data.FullName +")").attr('value', data.Id).trigger('change');
Upvotes: 0
Reputation: 768
Use .val()
$(<identifier>).val("15");
Here is some reference: http://api.jquery.com/val/
Upvotes: 1