How to remove the first character of link (anchor text) in JavaScript?

Here, we have set “Aabout_us” and “Hhome_page” with incorrectly spellings as anchor text.

You can use substring(1) along with innerHTML to remove the first character and display them correctly as “about_us” and “home_page” respectively.


 Live Demo

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<link rel="stylesheet" href="//">
<script src=""></script>
<script src=""></script>
<link rel="stylesheet" href="
<div class="linkDemo">
<a href="">Aabout_us</a>
<div class="linkDemo">
<a href="">Hhome_page</a>
   [...document.querySelectorAll('.linkDemo div a')].forEach(obj=>

To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.


This will produce the following output with the correct forms after removing the first character −