GetElementById Javascript DOM Method

  • JAVASCRIPT
  • CODING TIPS

Published on 2018-08-10

The Document method getElementById(String) is a fast way of returning an HTML Element Object representing the element that matches the specified id string parameter.

Quick Usage

var element = getElementById("html_element_id_attribute");Copy code to the clipboard

Details

  • Syntax

    var element = getElementById(id);Copy code to the clipboard
  • Paramenter

    The id parameter is a string with the html element id attribute to be searched.

  • Return Value

    HTML Element Object or NULL.

  • Support

    All browsers.

Rafael Caferati

Full Stack Web Developer, UI/UX Javascript Specialist.

<[{ Part-time developer – full-time geek }]>

Avatar