I have a list with checkboxes like this:
<ul class="cate_select_ul">
<li>
<!-- outer checkbox A -->
<label><input value="251" type="checkbox" name="post_category[]">Automobiles & Transport</label>
<ul class="children">
<li>
<!-- inner checkbox A -->
<label><input value="252" type="checkbox" name="post_category[]">Car Parts</label>
</li>
</ul>
</li>
<li>
<!-- outer checkbox B -->
<label><input value="251" type="checkbox" name="post_category[]">Automobiles & Transport</label>
<ul class="children">
<li>
<!-- inner checkbox B -->
<label><input value="252" type="checkbox" name="post_category[]">Car Parts</label>
</li>
</ul>
</li>
</ul>
I want to check if the inner checkbox is checked or not. If so I want to change the style of the label around the parent outer checkbox. I tried this but it won't work properly:
if($('ul.children input[name="post_category[]"]:checked').length > 0){
$("this").parent().parent().parent().parent().children("label").css({"color":"red"});
}
Any ideas on how to make this work?