How to remove first character from a string in jQuery

  14926 views   2 years ago jQuery

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.

Let's check out an example to understand how this method basically works:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery Remove first Character from String</title>
<script src=""></script>
        var fid = $(this).attr("href");
        var itemId = fid.substring(1, fid.length);
        alert("The ID of the linked image is - " + itemId);
    <a href="#balloons">Show Balloons</a>
    <img src="balloons.jpg" style="margin-top: 1000px" alt="Hot Air Balloons" id="balloons">


Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]