Can't get selected value from dropkick customised <select>
-
24-03-2021 - |
سؤال
I've just started using dropkick by Jamie Lottering and have my select lists transformed into customizable HTML dropdowns. Great! My only issue is I can't find a way to retrieve the selected value from the dropdown.
$('.change').dropkick({
change: function (value, label) {
alert('You picked: ' + label + ':' + value);
}
});
The site shows the above callback example, but I can't understand how I get the value for a given id rather than have it alerted when it changes?
I want to be able to say...
$("#myselect").val()
المحلول
The answer is in your question.
Suppose I have 2 select elements
<select id="select1" class="my-select">
<option>....</option>
<option>....</option>
<option>....</option>
</select>
<select id="select2" class="my-select">
<option>....</option>
<option>....</option>
<option>....</option>
</select>
I can style them using
$(".my-select").dropkick();
and get values using
$("#select1").val();
$("#select2").val();
.
لا تنتمي إلى StackOverflow