How do I remove all <li></li>
elements with an empty <a></a>
tag?
Example:
<li><a href=''>List item</a></li> //Do not delete
<li><a href=''></a></li> //Delete
You could combine the :has()
/:empty
jQuery selectors:
Example Here
$('li:has(a:empty)').remove();
Use following script
$("li a:empty").parent().remove();
For reference - https://api.jquery.com/empty/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With