Question

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()  
Was it helpful?

Solution

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();

.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top