且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery的阿贾克斯复选框状态

更新时间:2023-10-15 09:02:46

 如果($(#yourCheckboxID)是(:选中)){
    //复选框被选中
} 其他 {
    //复选框未选中
}
 

将做的工作。

I have checkboxes on my page for which I would like to send their state back to the database via ajax. I know how to use jquery with ajax, but I don't know how to get the checked state, both checked and unchecked along with the id of the checkbox so I can send it back to the server.

Any ideas?

if ($("#yourCheckboxID").is(":checked")) {  
    // checkbox is checked 
} else {
    // checkbox is not checked 
}

will do the job.