Topic: Material Select Set selected value
Michal Szymanski staff pro premium priority answered 8 years ago
dejan.mauer pro answered 8 years ago
<div class="col-md-4 input-field">
<select id="selectDiscount">
<option id="selectDiscountNone" selected value="None">Not specified</option>
<option id="selectDiscountMoney" value="Money">in money</option>
<option id="selectDiscountPercent"value="Percent">in percent</option>
</select>
</div>
How it is possible to select, for example, second option as with JavaScript?
Bartłomiej Malanowski staff pro premium answered 8 years ago
dejan.mauer pro answered 8 years ago
Rafael Pujol answered 7 years ago
var element = $("#youselectId")
element.prevAll('.select-dropdown').children('li:eq(2)').trigger('click');
you can remplace the number 2 with the item id that you want select
var changeSelectPickerValue = function (id, value) {
var element = $("#" +id)
element.prevAll('.select-dropdown').children('li:eq('+value+')').trigger('click');
}
Furey commented 7 years ago
$(#element_id)prevAll(‘.select-dropdown’).children(‘li:contains(‘+value+’)’).trigger(‘click’);FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No