parents
Using the parents
property, you can easily get all parent element instances of the current element, which will be returned as an array.
<script src="https://cdn.jsdelivr.net/gh/kirakiray/ofa.js@4.5.26/dist/ofa.min.js"></script>
<div>
<ul>
<li>I am 1</li>
<li id="target">I am target</li>
<li>I am 3</li>
</ul>
</div>
<div>
logger: <span id="logger"></span>
</div>
<script>
setTimeout(()=>{
$("#logger").text = $("#target").parents.map(e => e.tag);
},500);
</script>