I have html written on a page like this that I can not control and I can only get access to it using jquery, which I need your help to solve.
<span class="breadcrumb">
<a href="http://www.example.com" class="breadcrumb"></a>Home /
<a href="http://www.example.com" class="breadcrumb">Home</a> /
</span>
I would like to hide only the “Home /” text from the first line that has the empty link. This issue is the text is not wrapped in the link, but is plain text.
But I want to keep the second line visible that contains the link
<a href="http://www.example2.com" class="breadcrumb">Home</a> /
You can get the .contents().. then use .slice() to get the text portion that you don’t want
http://jsfiddle.net/3gpgY/
if you want to remove the anchor before the text too, just change the starting index
http://jsfiddle.net/eK7F7/