1if(document.getElementById("myElmentID").classList.contains("hidden")){
2// I have the 'hidden' class
3}
1const element = document.querySelector("#box");
2
3element.classList.contains("active");
1//How to check if class attribute contains something?
2//https://stackoverflow.com/questions/34992613/how-to-check-if-class-attribute-contains-something
3//el is the web element
4if(el.getAttribute("class").split(" ").contains("disabled"))
5{
6 //your code
7}
8
9or
10
11#region HTML Method
12public static bool hasClass(WebControl element, string strClass)
13{
14 return Convert.ToString(element.Attributes["class"]).Split(' ').Contains(strClass);
15}
16#endregion