getElementsByClassName

The getElementsByClassName JS Document returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes.

Syntax

collection = document.getElementsByClassName(classNames)
collection = element.getElementsByClassName(classNames)

Parameters

classNames

A space-separated list of classes.

Examples

1 · document · all

2 · document · first

3 · document · last

4 · element · all

5 · element · first

6 · element · last

7 · multiple

adoptNode

characterSet

compatMode

contentType

createCDATASection

createComment

createDocumentFragment

createElement

createElementNS

createProcessingInstruction

createTextNode

doctype

Document

documentElement

documentURI

exitPictureInPicture

getElementsByTagName

getElementsByTagNameNS

implementation

importNode

pictureInPictureEnabled

URL

write

writeln

Web Hypertext Application Technology Working Group (WHATWG)

Home Menu