Interview Question

Interview Deerfield, IL

Why does Javascript have two ways of getting HTML elements

  for example one way is to use getElementByID and another is document.[element].[value]

Interview Answer

1 Answer


getElementByID is just a DOM method that provides a shortcut to get to the element its ID attribut. The same element is still located in the DOM tree and can be accessed if we know his full path. There are more than 2 ways: by class name by tag name etc... on Apr 14, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.