javascript - How to remove only text from link wrapping both text and image, with jquery? -
i have webpage contains list. in each li there tag. tag contains both text , image. here html:
<li class="li-one" style=""> <a href="#" onclick="return false"><img class="theimg" src="...." width="18" height="12" alt="" title="">mytext</a> </li>
i tried using jquery image removed too:
jquery(document).ready(function($){jquery(".li-one").text("");});
how can remove text (mytext) jquery?
here's solution removes text nodes:
$('.li-one a').contents().each(function () { if (this.nodetype == 3) $(this).remove(); });
Comments
Post a Comment