Reputation: 14912
I have a page with links that look like this:
<a class="title" href="#">Recipes using <b>veal</b> - My Recipes</a>
I want to remove all the "- My Recipes" from these links, leaving (in this case):
Recipes using <b>veal</b>
I have tried many variations on $('a.title').replace( "- My Recipes", "" );
I think I must be targeting it wrong.
Upvotes: 1
Views: 108
Reputation: 95024
The .html method can handle it:
$('a.title').html(function ( i, html ) {
return html.replace( "- My Recipes", "" );
});
Probably better though to instead change what's returning this content so that it isn't there to begin with.
Upvotes: 1
Reputation: 3118
you can do:
$('a.title').each(function(){
$(this).html($(this).html().replace( "- My Recipes", "" ));
});
Upvotes: 2