Get Class List For A Div With JavaScript
> Here we consider how to Get Class List For An Element With JavaScript.
> Suppose we have a Div with multiple Classes as shown below.

> The above Div contains three Classes and its ID is DivID.
> For getting the list of all classes into an array, we can follow below shown code.
var list = document.getElementById('DivID').className.split(/\s+/);
> For getting a particular Class from the above list, we can follow below code.
var list = document.getElementById('DivID').className.split(/\s+/);
for (var i = 0; i < list.length; i++) {
if (list[i] === 'Class Name') {
// You Code Here....
}
}
> That's only, by using above code we can Get The Class List For Element With JavaScript.
Watch Video of this Content on Video Steaming