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

it2025-04-21  5

 

 

获取checkbox是否选中:

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

获得的值为true或false。

 

设置checkbox是否选中:

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

 

转载于:https://www.cnblogs.com/lhlong/p/11253536.html

最新回复(0)