0

I'd like to ask how to get Jquery object of checkboxes that are checked.

I have several checkboxex that have "checkboxes" class. some are checked, and some others are not checked.

<input type="checkbox" class="checkboxes" checked="checked" />

I put $('.checkboxes') into checkboxes variable.

var checkboxes = $('.checkboxes');

But I don't know what to write after this.

Could anyone help me?

Thanks in advance :)

1
  • get all selected. var checkValues = $('input[class=checkboxes]:checked'); Commented Aug 28, 2013 at 10:23

2 Answers 2

2

jQuery has a selector for checked or selected items: :checked. So to get all checked checkboxes into an object use this:

var checkedBoxes = $( '.checkboxes:checked' );
Sign up to request clarification or add additional context in comments.

Comments

0

You could do something like this:

$(function() {
    $('.checkboxes').click(function() {
        alert($(this).val() + ' ' + (this.checked ? 'checked' : 'unchecked'));
    });
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.