Input element

Can someone let me know why the console logs different values as I refresh the page? Sometimes I get

<input id="test" type="button" /> and sometimes I get input#test

let myButton = document.getElementById("test");
console.log(myButton);

myButton.addEventListener("click", function (e) {

  console.log(myButton);
  
});


This one’s actually the object map view. If you drop down the arrow next to it, you’ll see all the properties of the element.

It seems to be random; if you absolutely need it to be one way or the other, use console.dirxml (for the HTML type) or console.dir (for the object type).

i don’t need it. I was curious why it changes at random as I refresh the page

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.