You can also do this:

$(':checkbox').map(function() {
 return this.value;
});

or, if you just want an array of checked checkbox values, do this:

$(':checkbox:checked').map(function() {
 return this.value;
});


--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On May 6, 2009, at 2:26 PM, Charlie Griefer wrote:


On Wed, May 6, 2009 at 10:20 AM, hellolindsay <hellolind...@gmail.com> wrote:

Let's say I want an array of all the values for checked checkboxes on
my page. How do I do this?
This:

$('input:checkbox:checked').val()

..only returns the first value. Is there a function that will return a
javascript array of values?

$('input:checkbox').serializeArray();

(taken from 
http://groups.google.com/group/jquery-en/browse_thread/thread/2a24fbda70c64670)

--
I have failed as much as I have succeeded. But I love my life. I love
my wife. And I wish you my kind of success.

Reply via email to