/

HTML / CSS / JavaScript Tutorial

JavaScript Document own method: getElementsByClassName()

[this page | pdf | back links]

The getElementsByClassName() method (when applied to the document object of the JavaScript DOM) returns a NodeList containing all the elements 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.

 

document.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