javascript - Jquery - How to remove text after link inside last item in list? -
i need removing text jquery after link inside last item in list. thank help.
html:
<ul id="mylinks" style="text-align: left; margin-left: -25px;"> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> {* | remove *} </ul>
what trying remove text node not element, please use .contents()
try,
$('#mylinks').contents().last().remove();
demo
according new requirement can try,
$('#mylinks li:last').contents().last().remove();
Comments
Post a Comment