Using javascript/jquery to remove text after a certain character

Viewed 18850

Is there a way to replace/remove the text only after a certain character using jQuery or Javascript? I want to remove text after the dot '.' from an element.

8 Answers

for me splice works, I basically use this for removing characters after a hyphen or a comma etc.

var text = 'Tellme.more';
text.split('.')[0]);
//Consoles out -> Tellme
Related