1. 程式人生 > ># jquery checkbox父類與子類,全選中/全部不選中問題

# jquery checkbox父類與子類,全選中/全部不選中問題

jquery checkbox父類與子類,全選中/全部不選中問題

1.> input程式碼

input程式碼 2.jquery實現程式碼 加粗樣式 **$("[name=‘che’]").click(function(){ //當前點選的id,等於它父類的class var eleid = $(this).attr(“id”); //當前點選的class,等於它子類的ID var eleclass = (this).attr("class");if((this).attr("class"); if(

;if((this).is(’:checked’)){ //如果子類選中,則父類選中 $("."+eleid).prop(“checked”,‘true’); //如果父類不/選中,則子類不/選中 $("#"+eleclass).prop(“checked”,‘true’); }else{//如果父類不選中,則子類不選中 $("."+eleid).removeAttr(“checked”); } //子類都不選中,則父類不選中 var flag = false; KaTeX parse error: Expected '}', got 'EOF' at end of input: …ction(){ if(
(this).is(’:checked’)){ flag = true; } }) if(flag){ //如果flag=true,則子類有選中的,則父類選中 $("#"+eleclass).prop(“ckecked”,‘true’); }else{ //如果flag=flase,則子類沒有選中的,則父類不選中 $("#"+eleclass).removeAttr(“checked”); } }) }