Reputation: 3791
How do you target the children of children indefinately in jQuery. I can find the first level children using .children()
but can't go any deeper than that.
$('[data-snap-ignore="true"]').children().attr('data-snap-ignore', true);
I am basically having to find an element with attribute data-snap-ignore="true" and add that attribute to every child, grandchild, great grandchild and so on and so forth.
Upvotes: 0
Views: 65
Reputation: 56539
Try this
var ch = $('[data-snap-ignore="true"]').children(); //returns all children
$.each(ch, function (i, j) {
$(j).attr('data-snap-ignore', true);
});
Upvotes: 0
Reputation: 388446
Use .find('*')
$('[data-snap-ignore="true"]').find('*').attr('data-snap-ignore', true);
Upvotes: 1
Reputation: 2375
Try this way : this will find all children's having attribute 'data-snap-ignore
'
Further Reading : .find()
$('[data-snap-ignore="true"]').find('[data-snap-ignore]');
Upvotes: 1