Petrucho Posted March 19, 2014 Share Posted March 19, 2014 I have "Checkbox" input with multiple values. <input type="checkbox" name="drug" value="1" /><input type="checkbox" name="drug" value="2" /><input type="checkbox" name="drug" value="3" /> I want to run through this array and alert() all the values. I'm guessing I should use Jquery's .each() command but I'm not sure how to use it. the problem is, I don't understand how to use it so I can get the key and it's value. $.each($("input[name='drug']"),function(i,v){ alert(i+": "+v);}); What am I missing in the main idea? Link to comment Share on other sites More sharing options...
thescientist Posted March 19, 2014 Share Posted March 19, 2014 if you want to iterate over a collection of DOM elements, you'll want to implement like in the examples here https://api.jquery.com/each/ Link to comment Share on other sites More sharing options...
Petrucho Posted March 19, 2014 Author Share Posted March 19, 2014 I got to this page in the Jquery documentation: https://api.jquery.com/jQuery.each/ Thanks for the help, the idea is clear to me now. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now