Reputation: 11
I have an asp.net DropdownList Control. when i use this code
var id = $("[id*='drpCategory'] option:selected").val();
the id is always come first index of dropdown. How can i get other selected values. ?
Upvotes: 1
Views: 651
Reputation: 48813
Try like this:
var values = $("select[id*='drpCategory']").map(function(){
return this.value;
}).get();
and you will have the selected values of all dropdown
s.
Upvotes: 2
Reputation: 144739
you can loop through the select
elements, please note that using attribute selector alone is too slow, try this:
$("select[id*='drpCategory']").each(function(){
alert(this.value)
})
Upvotes: 3
Reputation: 46657
jquerys .val()
will return the selected value of your drop down, or an array of selected values if the drop down allows multiple.
var selectedItems = $('[id*="drpCategory"]').val();
Upvotes: -1
Reputation: 1930
$("#input_id").click(function(){
var id = $("#drpCategory option:selected").val();
})
Upvotes: 0