JSFiddle - React, Tailwind, and code Playground
by rufwork
HTML
<div class="family">
Mirror. Razor.
<div class="grandparentDiv">
Grandparent
<div class="parentDiv">
Parent
<div class="childDiv">
Child
</div>
<div class="siblingDiv">
Sibling
</div>
</div>
<div class="uncleDiv">
Uncle
<div class="cousinDiv">
Cousin
</div>
</div>
</div>
<div class="greatUncleDiv">
Great Uncle
</div>
</div>
<br><hr><br>
<div id="output"></div>
JavaScript
$(".family").on("click", "div", function(event){
// let's find our great uncle.
var $family,
$familyMember = $(event.target),
// http://viralpatel.net/blogs/jquery-get-text-element-without-child-element/
strFamilyMemberText = $familyMember
.clone() //clone the element
.children() //select all the children
.remove() //remove all the children
.end() //again go back to selected element
.text() //get the text of element
.trim();
$family = $familyMember.closest(".family");
$("#output").append(strFamilyMemberText + " found " + $family.find(".greatUncleDiv").text().trim() + "<br>");
event.stopPropagation(); // don't need all the ancestors firing off.
});