Reputation:
<header data-ride="share">
<div class="child__one">
<div class="child__two">
<div class="child__three"></div>
</div>
</div>
</header>
Is possible to catch the header tag from the child__three??
For example:
var parent = $('.child__three').parents('[data-ride="share"]');
This won't work at all.
Thanks.
Upvotes: 1
Views: 39
Reputation: 30587
Use jQuery closest()
var parent = $('.child__three').closest('[data-ride="share"]');
The problem with parents() is it can return multiple objects.
See Difference between jQuery parent(), parents() and closest() functions
Upvotes: 1