<ul class='my-class'>
  <li><span>Hi</span><a>First</a><em>Bye</em></li>
  <li><a><em>Second</em></a><span>Hi</span></li>
  <li><a><span>Third</span></a></li>
    <li><a><span>Fourth</span></a></li>
</ul>
<ul class='my-class second'>
  <li><a><span>First</span></a></li>
  <li><a><em>Second <span>Second</span>  Second</em></a></li>
  <li><a>Third</a></li>
  <li><a>Fourth</a></li>
</ul>
html {
  background: #fbdf00;
  font-size: 20px;
}
let nodes = document.querySelectorAll('.my-class a');

for (let i = 0; i < nodes.length; i++) {
    
    if (nodes[i].querySelector('span')) {
        
      nodes[i].querySelector('span').style.color = 'red';
   
   }

}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.