javascript has class in classlist code example
Example 1: js check for class in classList
element.classList.contains(className);
Example 2: class list contains class java
List<Card> hand = ...;
for(Card card : hand){
if (card instanceof AceOfDiamonds) return true;
}
Example 3: add to classlist javascript
Add multiple classes to a <div> element:
document.getElementById("myDIV").classList.add("mystyle", "anotherClass", "thirdClass");
Remove a class from a <div> element:
document.getElementById("myDIV").classList.remove("mystyle");
Remove multiple classes from a <div> element:
document.getElementById("myDIV").classList.remove("mystyle", "anotherClass", "thirdClass");
Toggle between two classes for a <div> element:
document.getElementById("myDIV").classList.toggle("newClassName");
Find out if an element has a "mystyle" class:
document.getElementById("myDIV").classList.contains("mystyle");