Jquery判断复选框checkbox是否被选中?(已解决)
<input type="checkbox" id="IfSave" name="fruit" value ="apple" > </input>
alert($("#IfSave").val()); // 取value值
if ($("#IfSave").attr("checked") == true) {
alert("选中!");
}
else { alert("未被选中呀!"); }
// 选择和取消代码
$("#IfSave:checkbox").attr('checked', 'true');
$("#IfSave:checkbox").attr('checked', 'flase');
本文介绍如何使用JQuery来判断复选框checkbox的状态,包括是否被选中,并提供了设置选中状态的方法。
374

被折叠的 条评论
为什么被折叠?



