user1734190
user1734190

Reputation: 167

Error to remove text from text function in jquery

I want to remove the text. I'm using the following function.

 var ta=$('title', item).text();

The out put of this is "Cases That Charge On-The-Go(video)". I want to remove the "(video)" from the text. plz let me know ho

Upvotes: 0

Views: 43

Answers (2)

chridam
chridam

Reputation: 103375

var ta = $('title', item).text().replace("(video)", "");

And if you want to remove any text between the parenthesis:

var ta = $('title', item).text().replace(/\(.*?\)/, "");

DEMO: http://jsfiddle.net/VNbjg/

Upvotes: 0

VisioN
VisioN

Reputation: 145408

You may use replace():

ta = ta.replace("(video)", "");

So, to replace the text in the element try the following:

$("title", item).text(function(i, text) {
    return text.replace("(video)", "");
});

Upvotes: 3

Related Questions