JSFiddle - React, Tailwind, and code Playground
by Shajeer Ahamed
HTML
<div>
<span>
<span>
<a class="type-1">as</a>
</span>
</span>
</div>
<div>
<a class="type-2">asd</a>
</div>
<div>
<a class="type-3">asd</a>
</div>
CSS
.type-1-parent{
background:red;
}
.type-2-parent{
background:blue;
}
.type-3-parent{
background:green;
}
JavaScript
$(".type-1").closest("Div").addClass("type-1-parent");
$(".type-2").parent("Div").addClass("type-2-parent");
$(".type-3").parent("Div").addClass("type-3-parent");