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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -