JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<body>
<div>
<ul>
<li></li>
</ul>
</div>
</body>
</html>
JavaScript
function traverse($node){
while ( $node.get(0) !== $("html").get(0) ) {
console.log($node);
traverse($node.parent());
}
}
//traverse($("ul li"));