0

In Javascript, How element objects are thrown on calling the id ? I am little surprised and confused about this behaviour.

Example:

<input type="hidden" value="test" id="idtest">

When I call "idtest", it returns the whole object.

It is behaviouring the same for all id elements not only for input elements.

When I use the global variable same as "idtest", It will cause an issue with global variables.

How it is working ?

How can I prevent this ?

Nandakumar
  • 1,071
  • 2
  • 11
  • 30

0 Answers0