Guys i want to know how can i remove a symbol and everything after that symbol from a string with jQuery or JavaScript.
Here is my code:
var optionValueText = $.trim($('[data-divNumber="on"] :selected').text());
The variable optionValueText
is printing results like My first result +24.00 euros
So what i want to do is to remove everyting after the +
plus symbol including the plus symbol itself.
So for final result of my example i want to receive a result like this My first result
and that is it!
How can i make it?
Thanks in advance!
Use
optionValueText = optionValueText.substring(0, optionValueText.indexOf('+'));
alert(optionValueText);
Explanation : Find index(character position) of + and take substring from 0 till that index of + .
For more info read here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.