Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
37
rated 0 times [  39] [ 2]  / answers: 1 / hits: 24313  / 12 Years ago, fri, november 30, 2012, 12:00:00

How do I remove the last line n from a string, if I dont know how big the string will be?



var tempHTML = content.document.body.innerHTML;
var HTMLWithoutLastLine = RemoveLastLine(tempHTML);

function RemoveLastLine(tempHTML)
{
// code
}

More From » jquery

 Answers
6

Try:



if(x.lastIndexOf(n)>0) {
return x.substring(0, x.lastIndexOf(n));
} else {
return x;
}

[#81690] Thursday, November 29, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yesseniadajab

Total Points: 258
Total Questions: 101
Total Answers: 127

Location: Mexico
Member since Mon, Sep 12, 2022
2 Years ago
;