JSFiddle - React, Tailwind, and code Playground
HTML
<p id ="test">First Paragraph</p>
<p>Second Paragraph</p>
<p>Yet one more Paragraph</p>
JavaScript
$('p').click(function(){
parentEls = $(this).parents()
.map(function () {
return this.tagName;
})
.get().join(", ");
alert(parentEls);
});