html5中checkbox的选中状态的设置与获取

获取checkbox是否选中:

$("#checkbox").is(":checked");

获得的值为true或false。

设置checkbox是否选中:

$("#checkbox").attr("checked", true);//设置为选中状态
$("#checkbox").attr("checked", false);//设置为未选中状态

猜你喜欢

转载自www.cnblogs.com/lhlong/p/11253536.html