Difference between getElementById methods from DOM and Document classes

Viewed 10985

GWT offers two ways of retrieving an HTML element by its unique ID.

What's the diference (if there is one) between :

  • DOM.getElementById("divID") :

Gets the element associated with the given unique id within the entire document.

@param id the id whose associated element is to be retrieved
@return the associated element, or null if none is found

  • Document.get().getElementById("divID") :

Returns the Element whose id is given by elementId. If no such element exists, returns null. Behavior is not defined if more than one element has this id.

@param elementId the unique id value for an element
@return the matching element

2 Answers
Related