Remove First Character From the String Using jQuery

Last Updated on December 18, 2020 by Roshan Parihar

In this tutorial, learn how to remove first character from the string on button click using jQuery. The short answer is to use substring() or slice() to remove the first letter from the string.

The tutorial removes only the 1st character from the string. You have to pass 1 as the argument of the function to remove the first letter of the string with jQuery.

jQuery Substring() to Remove First Character

To remove the first letter from the string, you can use jQuery substring(). You have to first use the jQuery text() to get the text content. After that, you have to use the substring() with argument ‘1’ to remove the first letter of the string.

Test it Live

Output

&This is my string

The above example contains the ‘&’ symbol as the first character. Click the above button to remove the ‘&’ letter from the string. You will get the string without the first letter of the string.

Delete First Character Using Slice()

In addition to the above example, you can also use the jQuery slice() to remove the first letter. This works same as substring() and removes the first letter of the string. You need to first get the text content using text(). After that, use the slice() with argument ‘1’ to remove the 1st letter.

Test it Live

Output

@This is my string

Click the above-given button to remove the first letter of the string. This gives you the same string as you got with the substring() of jQuery in the previous example.

You may also like to read.

I hope, you like this tutorial on how to remove the first letter from the string using jQuery.