If you want to only do something to elements that are selected as in this case (here we want to do something if the checkbox is checked) you can simplify the code to
$('#edit-checkbox-id:checked'),each(
function() {
// Insert code here
}
);
and the function will only run if the checkbox with the selected id is checked.
If you use a selector that can return more than one element, the function is applied each of the matching elements (one at a time), so
$("input[@type=checkbox][@checked]").each(
function() {
// Insert code here
}
);
will run the function for each checkbox that is checked.
 | 다 빈치 코드 2
댄 브라운 지음, 양선아 옮김 / 북스캔(대교북스캔) / 2004년 7월
7,800원 → 7,020원(10%할인) / 마일리지 390원(5% 적립)
|
|