I want to remove first character from link's text with jQuery.
<span class="test1"> +123.23 </span>
<span class="test2"> -13.23 </span>
I want to remove the "+" and "-" from with jQuery.
Output:
<span class="test1"> 123.23 </span>
<span class="test2"> 13.23 </span>
Answer: Use the JavaScript substring() method You can use the JavaScript substring() method to remove first character form a string. A typical example is removing hash ( # ) character from fragment identifier.
To delete the first character from a string, you can use either the REPLACE function or a combination of RIGHT and LEN functions. Here, we simply take 1 character from the first position and replace it with an empty string ("").
var val = $("span").html();
$("span").html(val.substring(1, val.length));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With