Home › Forums › JavaScript › [Solved] Add Class to Parent if Checkbox is Checked › Re: [Solved] Add Class to Parent if Checkbox is Checked
December 30, 2011 at 9:09 am
#93709
Mottie
Member
This code: $(this).parent().length
points to the parent of the link, which is the LI. Try this (demo):
$(this).parent().siblings().length;
Or this would work too, but a bit more messy
$(this).parent().parent().find('li').length;
It uses .parent().parent()
instead of .closest('ul,ol')
since I’m not sure it works and I’m too lazy to test it.