I am trying to get a list of values within a div that I will format later using the .each() method. They are input values which are hidden my html and jquery call looks like this.
<div id="container_0">
<input type="hidden" id="check_data" value=10>
<input type="hidden" id="check_data" value=20>
</div>
Jquery:
var list = $('#container_0 input#check_data');
$(list).each(
function() {
alert($(this).val());
}
);
This however is not returning any values. Any help would be greatly appreciated.
You can’t use the same ID multiple times, this is invalid HTML. When you do this, any results will be unpredictable, especially across browsers.
This should work to alert the values though:
If you used a class, like this:
Then this would find only those inputs: