I have a string “-123445”. Is it possible to remove the ‘-‘ character from the string?
I have tried the following but to no avail:
$mylabel.text("-123456");
$mylabel.text().replace('-', '');
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since
text()gets the value, andtext( "someValue" )sets the value, you just place one inside the other.Would be the equivalent of doing:
EDIT:
I hope I understood the question correctly. I’m assuming
$mylabelis referencing a DOM element in a jQuery object, and the string is in the content of the element.If the string is in some other variable not part of the DOM, then you would likely want to call the
.replace()function against that variable before you insert it into the DOM.Like this:
or a more verbose version: