Doubt to open console in browser

How to open console in browser for getElementsById

Hi there,
To check the output of your code in console, you need to code something like ‘console.log( function call)’ and right clicking the web page<inspect<console
Other way, to check in the terminal-
Node should be installed in the ‘javascript’ terminal and need to run “node nameofthefile.js”

Hi @adityapy2409,

In the topic “getElementById in Javascript” of the training, we have given detailed explanation regarding the same.
Please check and let us know if you have any queries

To open the console in your browser and use getElementById, follow these steps:
Use getElementById:
In the Console, you can type JavaScript commands. For example, to select an element with the ID output, type:


Press Enter to execute the command.

Let me know if you have any other questions

When you are in browser use the shortcut key - Ctrl + Shift + i (This is for chrome might work in other browsers too)

Hi @adityapy2409,

To open console in browser for getElementsById in Google Chrome, you can try any one of the techniques below:

  1. You can directly use the shortcut and press ‘Ctrl+Shift+J’
  2. Or you can directly right click on the page, select ‘Inspect’ and then go to the ‘Console’ tab.

In the console, you can use *document.getElementById('elementId')* to select an element by its ID. Replace *'elementId'* with the actual ID of the element you want to select.

Hi @adityapy2409 ,

To open your console: right click on your web page, click on inspect, and then click on the console tab.
If you want to print something in the console you can use the ‘console.log()’ function within your code like this and replace ‘your text’ with what you want to print:

console.log(‘Your text’)

You can also use console.log() to print the value of variables:


If say you have a variable declared as var a = 10, typing console.log(a) in your code will print it’s value, i.e., 10 on the console. You can do the same by getting the value of an element using getElementById() and assigning it to a variable after which you can print it in the console with console.log().

If you want to use ‘getElementById()’ directly in the console then type this in the console while replacing desired_ID with the id of the element whose value you are trying to get:


you can use the shortcut key for chrome ie ctrl+ shift +i to open the browser console.