Please help me figure out how to add a class to li where an anchor is present.
<ul>
<li>abc</li>
<li>abc</li>
<li><a>abc</a></li>
<li><a>abc</a></li>
<li>abc</li>
</ul>
I want to add a class to first li where anchor tag is present within the ul
Assuming I’ve understood what you mean, try this:
Fiddle to show it works
EDIT
This works too, and should be a little faster: