1if ($(".mydivclass").length){
2 // Do something if class exists
3} else {
4 // Do something if class does not exist
5}
1if ($(".mydivclass")[0]){
2 // Do something if class exists
3} else {
4 // Do something if class does not exist
5}
1if ($(".mydivclass")[0]){
2 // Do something if class exists
3} else {
4 // Do something if class does not exist
5}
6
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