Xavier
Xavier

Reputation: 8362

Find a text string, modify a text string in jQuery

I am parsing JSON in jquery and i wish to remove some text from the "name" field on a certain element.

I am trying the following code but it doesn't seem to work:

$('#content ul li:contains("Industrial Average")').replace("");

Here is a fiddle to the code:

http://jsfiddle.net/c2VeD/1/

Upvotes: 0

Views: 104

Answers (1)

Sarfraz
Sarfraz

Reputation: 382656

Try:

$('#content ul li:contains("Industrial Average")')
 .html($('#content ul li:contains("Industrial Average")')
 .text().replace("Industrial Average", ""));

Upvotes: 1

Related Questions