JSFiddle - React, Tailwind, and code Playground

by Gabriele Petrioli

HTML

<div> 
    <div>
        <div>
            <ul> 
                <li>matched item (for link 1) where script is called from <strong>click</strong> </li>
            </ul>
        </div>
    </div>
    <a class="postMore">LINK 1</a>
</div>

<div> 
    <div>
        <div>
            <ul> 
                <li>matched item (for link 2) where script is called from  <strong>click</strong></li>
            </ul>
        </div>
    </div>
    <a class="postMore">LINK 2</a>
</div>

JavaScript

$('li').click(function(){
    
    var relatedLink = $(this).closest('div:has(a.postMore)').find('a.postMore');
    
    relatedLink.css('color','red');
    
});