ajpenalosa
5/17/2018 - 1:00 AM

Get Element By ID

The Document method getElementById() returns an Element object representing the element whose id property matches the specified string. Since element IDs are required to be unique if specified, they're a useful way to get access to a specific element quickly.

If you need to get access to an element which doesn't have an ID, you can use querySelector() to find the element using any selector.

https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById

var element = document.getElementById(id);