How to tell if an HTML element has a particular class in JavaScript? [duplicate]

sagichnicht<<

New Member
This question already has an answer here: Is there an easy way to tell if an HTML element has a specific class? For example:\[code\]var element = document.getElementById('something');if (element.class == 'car')\[/code\]Of course an element can have multiple classes, so maybe the \[code\]if\[/code\] statement would have to be of the following form?\[code\]if (element.class.includes('car'))\[/code\]
 
Top