Jun 10
There are 3 ways in jQuery to find a check box is checked or not.
// First way
$('#checkBox').attr('checked');
// Second way
$('#edit-checkbox-id').is(':checked');
// Third way for jQuery 1.2
$("input[@type=checkbox][@checked]").each(
function() {
// Insert code here
}
);
// Third way == UPDATE jQuery 1.3
$("input[type=checkbox][checked]").each(
function() {
// Insert code here
}
);
First two methods return true or false. True if that particular checkbox was checked or false if it is not checked. The third method iterates though all checkboxes with checked attribute defined and performs some action.










Aug 9, 2010 at 11:18 AM I am looking for a way to dynamically show content for one checked box at a time. I have 3 check boxes (1 - 3) I want to show the one closest to the top that is selected.<br />example: If I select 2 and 3. then the text from 2 is visible, not 3.<br />If I select 1 and 3 then the texzt from 1 is visible.<br />I can easily hide and show content, but not to this extent. I think the third function will work if i can figure out how to see if the box closest to the top is checked only show that content.