/

HTML / CSS / JavaScript Tutorial

JavaScript DOM HTML method: getElementsByClassName()

[this page | pdf | back links]

The getElementsByClassName() method (when applied HTML elements in the JavaScript DOM) returns a NodeList containing all the elements within the element with the specified class attribute.

 

It has the following syntax with the following parameters. It returns a NodeList representing a collection of all relevant elements, ordered as they appear in the source code.

 

element.getElementsByClassName(classname)

 

Parameter

Required / Optional

Description

classname

Required

String specifying the class name of the elements you want to obtain. To include multiple class names, separate individual class names by spaces

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile