Matt Coady
Matt Coady

Reputation: 3856

Remove word from substring

I've got a list of links that looks like this

How do I get jQuery to remove the string " (foo)" from the link text?

Upvotes: 0

Views: 96

Answers (2)

esorbma
esorbma

Reputation: 58

another alternative

$('li:nth-child(2)').replaceWith('<li>Item 2</li>');

Upvotes: 0

Ram
Ram

Reputation: 144689

$('a:contains(foo)').text(function(_, currentText){
   return currentText.replace('foo', '');
});

http://jsfiddle.net/EgHkr/

Upvotes: 3

Related Questions