twal
twal

Reputation: 7039

using Jquery to find out what check boxes are checked

I have a table that i am enumerating through my model with. I have this check box there for each row.

   <input type="checkbox" name="IsSelected" value="<%=item.PartNo%>" />

I would like to use jquery to find out which of the check boxes are checked I tried doing this

  var selected = $("#IsSelected").val();

but selected is just undefined. is there a way to do this? Thank you

Upvotes: 0

Views: 225

Answers (2)

dzida
dzida

Reputation: 8981

First of all you should change your code to

<input type="checkbox" id="IsSelected" name="IsSelected" value="<%=item.PartNo%>" />

You can use jquery .is(':checked') to determine if checkbox is checked or not.

Upvotes: -1

Adam
Adam

Reputation: 44919

var checkedCheckboxes = $("input[name='IsSelected']:checked");

checkedCheckboxes should then be a collection of the checked checkboxes

Upvotes: 2

Related Questions