jQuery的阿贾克斯复选框状态 [英] jQuery Ajax checkbox state

查看:124
本文介绍了jQuery的阿贾克斯复选框状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的网页复选框,我想通过AJAX发送他们的状态恢复到数据库中。我知道如何使用jQuery使用Ajax,但我不知道怎么弄的选中状态,无论选中和未选中的复选框的ID沿着这样我就可以将其发送回服务器。

任何想法?

解决方案

 如果($(#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.

这篇关于jQuery的阿贾克斯复选框状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆