Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove the first character from a link's text with jQuery?

Tags:

jquery

string

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>
like image 400
AlexC Avatar asked Nov 06 '09 01:11

AlexC


People also ask

How do I remove the first character of a string in jquery?

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.

How do you delete the first character in a string?

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 ("").


1 Answers

var val = $("span").html();
$("span").html(val.substring(1, val.length));
like image 84
ss. Avatar answered Oct 16 '22 21:10

ss.