จะเช็คว่า checkbox ถูกติ๊กหรือยังได้อย่างไร ใน jquery
- roteee's blog
- 6 comments
- 323 reads
เห็นว่าเป็นประโยชน์ เลยเอามา blog ไว้สักหน่อย จะได้เอาไว้เตือนความจำ :)
// 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
}
);