JSFiddle - React, Tailwind, and code Playground
by Karan1412
HTML
<html>
<head>
<title>parent</title>
</head>
<body>
<div>
This is Div element.
<p>This is paragraph element. It is inside Div element.<br>
<span>This is span element. It is inside paragraph element.<br>
<em id="target">This is emphasize element. It is inside span element.</em>
</span>
</p>
</div><br />
<input type="button" id="parent" value = "parents() of em" />
<input type="button" id="parents" value = "parents() of em filter by selector" />
<input type="button" id="reset" value="Reset" onclick="location.reload()" />
</body>
</html>
JavaScript
$(document).ready(function () {
var css = {
'color': 'Aqua',
'background-color': 'Yellow'
};
$("#parent").click(function () {
$("#target").parents().css(css);
});
$("#parents").click(function () {
$("#target").parents("div").css(css);
});
});