JSFiddle - React, Tailwind, and code Playground
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>parents demo</title>
<style>
b, span, p, html body {
padding: .5em;
border: 1px solid;
}
b {
color: blue;
}
strong {
color: red;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div>
<p>
<span>
<b>My parents are: </b>
</span>
</p>
</div>
<script>
var parentEls = $( "b" ).parents()
.map(function() {
return this.tagName;
})
.get()
.join( ", " );
$( "b" ).append( "<strong>" + parentEls + "</strong>" );
</script>
</body>
</html>