parentsUntil function in jQuery

Add suffiecient HTML in your html support code file:parents Until function in jQuery
<div class="target-parent" style="width:500px;">test(great-grandparent)
    <div>(grandparent)  
      <div>(direct parent)
        <span>span</span>
      </div>
    </div>   
  </div>

And then add the following script to change color until the specific parent does exist:
<script>
$(document).ready(function(){
  $("span").parentsUntil(".target-parent").css({"color": "red"});
});
</script>
Now you can see your output like this:


add variants in Shopifyexpoundsofttechsolution


parents Until function in jQuery