JavaScript Class Name Tutorial

ClassName Property

The className property sets or returns the class name of an element (the value of an element’s class attribute).

Syntax

Return the className property:

HTMLElementObject.className

Set the className property:

HTMLElementObject.className = class

Example: 1 

Set the class for an element with id=”demoDIV”

Example: 2

Toggle between two class names.

Take Your Free Live Demo Class Now

We Will Call Back You Shortly

Enter Your DETAILS BELOW

We Will Send You the Course Fees Details In Below Number

Enter Your DETAILS BELOW

We Will Call Back You Shortly

Enter Your DETAILS BELOW

We Will Call Back You Shortly

Enter Your DETAILS BELOW

Enter Your DETAILS BELOW TO take

free demo class