I have this:
<div id="container1"> <div class="block1"> <input class="pos2" type="checkbox" /><label>Category1</label><br> <input class="pos3" type="checkbox" /><label>Subcategory1</label><br> <input class="pos3" type="checkbox" /><label>Subcategory1</label> </div> <div class="block1"> <input class="pos2" type="checkbox" /><label>Category2</label><br> <input class="pos3" type="checkbox" /><label>Subcategory2</label> <input class="pos3" type="checkbox" /><label>Subcategory2</label> </div> </container> I am trying to use jquery to auto-check the checkboxes. For example: if I would check 'pos2' it would auto-check pos3.
I used this:
$("#container1 .block1 .pos2").click(function(){ $(".block1").children(".pos3").attr('checked', 'checked'); }); But I need it to only check 'pos3' from the div I clicked on.
Note: The checkboxes are generated with PHP from entrys in a database. Their numbers can vary, thus I can't use ids on elements.
Can anyone help me on this?
Thanks in advance!