How many types in getElementsBy ?
document.getElemetsById.
document.getElementsByClassName.
document.getElementsByTagName.
document.getElementsByName.
document.getElementsByTagNameNS.
what is the document.getElementsById ?
This method returns a single Element object representing the element whose id attribute matches the specified string. Element IDs are designed to be unique within a document, making this a fast and efficient way to access a specific element.
what is the document.getElementsByClassName ?
This method returns a live HTMLCollection of elements that have the specified class name(s). You can access individual elements within the collection by their index (e.g., collection[0]).
what is the document.getElementsByTagName ?
This method returns a live HTMLCollection of all elements with the specified tag name (e.g., "div", "p", "a").
what is the document.getElementsName ?
This method returns a live NodeList of elements that have the specified name attribute. This is commonly used for interacting with form elements like radio buttons or checkboxes.
what is the document.getElementsByTagNameNS ?
This method is similar to getElementsByTagName but is used for elements within a specified namespace, which is less common in standard HTML development.
Top comments (0)