<一>判斷checkbox的選中事件
var result=$(this).find("input[type='checkbox']").prop("checked");
result 是bool類型的值 true是選中的狀态 false是沒選中的狀态
checkbox标簽已有checked=checked但是不顯示勾選
if(dataBack.remind){ $("#isremind").prop("checked",true); }else{ $("#isremind").removeAttr("checked"); }
添加的時候用prop,取消用removeAttr。
<二>radio的選中狀态
//付款方式
$('div#pay-type input[type="radio"] ').each(function (e) {
var radiotype = $(this).attr("checked");
if (radiotype == "checked") {
paytype = $(this).attr("tid");
}
});
var radiotype = $(this).attr("checked");
如果radiotype == "checked" 就是選中
find就相當與children
closet就相當于parent
轉載于:https://www.cnblogs.com/xiaoyaodijun/p/4422114.html