If I have a bunch of label/selects like:
<label for="blah" class="myClass">
<select id="blah" multiple="multiple" size="5">
How would I get the value of the selected item based off the label?
So far I have..
$('label[class="myClass"]').each(function(){
var labelTxt = $(this).text();
var labelForTxt = $(this).attr('for');
var inputVal = $('#'+labelForTxt).val();
});
but inputVal isn't the value I expect to see. Instead I get either null/undefined. Am I missing something?
Thanks!
everything is fine, if you hav given close tag for label
and select
and options in select
.check the code , i have modified and implemented.
http://jsfiddle.net/XaMg9/5/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With