I have:
<li class="parent">
<a href="#">Text I WANT to remove</a>
<ul>
<li class="child">
<a href="#">Text I DO NOT WANT to remove</a>
</li>
</ul>
</li>
How do I remove text from the parent’s a element but not any of the childrens’?
EDIT: removed extra closing a tag for clarity.
Try using the
$("#element").text()function.Just set it to an empty string :
I am using the
>part of the selector to state that I want to use only the<a>tags that are direct children – that means they appear in the first level.