Objective:
Find all elements with the data-attribute parent-cat-number == my_cat_number.
As you can see from the markup I get the parent-category integer from the atribute "data-cat-number", but I fail at finding all the children with that as their parent-cat-number.
Here's an example of how it could look http://jsfiddle.net/jahrichie/jGpcx/ , but right now the click of a parent shows all children. I'd like to adapt it to only show the children of that element.
JS http://jsfiddle.net/jahrichie/jGpcx/
$('.parent-category').click(function () { var my_cat_number = $(this).attr('data-cat-number'); $(this).children().find("[parent-cat-number] = my_cat_number").show(); }) HTML
<div class="category-faceted"> <div class="parent-category" data-cat-number="1"> <a href="javascript:void(0)">Celebrity</a> <div class="child-category" parent-cat-number="1"> <a href="javascript:void(0)">Sub-Celebrity</a> </div> </div> <div class="parent-category" data-cat-number="2"> <a href="javascript:void(0)">Entertainment</a> <div class="child-category" parent-cat-number="2"> <a href="javascript:void(0)">Sub-Ent</a> </div> </div> </div>