Check boxes clicked all

后端 未结 2 1048
Happy的楠姐
Happy的楠姐 2021-01-26 05:19

I want to select the parent item when any of the child is clicked. This code is working checked and check.

$(function() {
  $(\".child\").on(\"click\",function(         


        
2条回答
  •  长发绾君心
    2021-01-26 05:46

    Adding the unordered list adds another layer of parent-children. Edit this line:

          $parent = $(this).parent().prevAll(".parent");
    

    to this:

      $parent = $(this).parent().parent().prevAll(".parent");
    

    to correctly point to your intended parent.

提交回复
热议问题