getElementsById() method is not allowing in sublime text

when i use the method getElementsById() method in sublime text and then moving to console page it shows that method is unavailable as i like i attached screenshot below
Screenshot 2022-04-19 134929

Hi there @kirthickrubhan123,
i believe the syntax of your code is correct,
its just that in the line below the starting script tag the correct syntax is,
document.getElementById(“output”).innerHTML=“New text”;

I believe with this small correction you will be able to run your code.

Hi @kirthickrubhan123,

It should be getElementById() instead of getElementsaById.

1 Like

thank you for your answer

thank you for your answer

use getElementById()

Yes it should be getElementById()

Hii @kirthickrubhan123
Method names are case-sensitive and spelling also matters a lot.
As you can observe in your code that you have written getElementsaById() instead of getElementById(). This method name follows camel case(Each word, except the first, starts with a capital letter) which should be taken care off.

5 / 5

getElementsById() is not a valid JavaScript method. The correct method is getElementById(), which is used to get an element from the HTML DOM by its ID.

If you are having issues with getElementById() not working in your Sublime Text editor, there could be a few reasons why. Here are some troubleshooting steps:

  1. Check the syntax: Make sure you have spelled the method correctly and that you are using the correct capitalization. The method name is case-sensitive and should start with a lowercase “g”.
  2. Check the HTML document: Ensure that the ID you are trying to access with getElementById() exists in your HTML document. If the ID does not exist, the method will return null.
  3. Check for JavaScript errors: If there are errors in your JavaScript code, they may prevent getElementById() from working correctly. Check the console for any error messages.
  4. Check your code structure: Make sure that your getElementById() method is called within a script tag or an external JavaScript file that is properly linked to your HTML document.

If you are still experiencing issues, try creating a new HTML and JavaScript file from scratch and see if getElementById() works in that document. If it does, then there may be an issue with your current code or file structure.

@jtjojothomas123 @sairamakula1999


It should be document.getElementById("output").innerHTML = "new text";

You have made a typo in getElementsById()