1

I want to display the HTMLInputElement object of an HTML input :

 <div>
  <input type="text" id="name" name="toto" value="test" />
</div>

JS script :

<script>
  const inputEl = document.getElementById("name"); 
  console.log(inputEl);
</script>

In the chrome console, I get this :

enter image description here

But I want to display it as an HTMLInputElement object.

In stackblitz console I get the object :

enter image description here

Thank you :)

But locally I dont get the object !!

abadou
  • 41
  • 6

1 Answers1

0

Not 100% sure what you mean by 'display as an HTMLInputElement'. If you want to see all its fields, you might want to use console.dir(inputEl).

  • Because in HTML, they say that any tag turns into an HTMLInputElement object, The HTMLInputElement interface provides special properties and methods for manipulating the options, layout, and presentation of elements. – abadou Jun 21 '20 at 10:06
  • In the stackblitz i got the object , but locally no :( see the screenshot in the top , i updated my question – abadou Jun 21 '20 at 10:19
  • @abadou What's happening is that `console.log()` uses `toString()`, which returns a custom string like the one in your first screenshot. If you use `console.dir()`, it evaluates the actual keys the object has and prints them, similar to the second screenshot. – Schwefelhexa Jun 21 '20 at 11:07