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:

http://jsfiddle.net/4q4tv/

$('.li-one a').contents().each(function () {     if (this.nodetype == 3)         $(this).remove(); }); 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -