Jump to content

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


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...