Jquery Check parent checkboxes in nested ul li

后端 未结 5 1960
情话喂你
情话喂你 2021-01-02 12:48

I have a script that will check and uncheck all children checkboxes in a nested list. I am now trying to get it so I can check a low level checkbox and it will check all the

5条回答
  •  死守一世寂寞
    2021-01-02 13:02

    You can use prevAll() also I have the same issue. In my case there are multiple checkboxes in li with labels, and each checkbox above target have class parent (generated in js)

    $(this).parents().prevAll('input:checkbox.parent').each(function () {
                           $(this).attr('checked', true);
                       });
    

提交回复
热议问题