Jump to content

Jquery problem with running through array, using .each()


Petrucho

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...