1

I found example in web with this usage. Basically as I see second way of getting DOM element by id is short. But i can't find any documentation regarding compatibility and real difference with this approach. Any explanation ?

<input type="button" id="elem" value="Click" />

var s = document.getElementById("elem"); 

console.log(s);

console.log(elem); // equalent to document.getElementById("elem")
Nikita P
  • 149
  • 5
  • 19

0 Answers0