check class exist or not in jquery code example
Example 1: javascript check if element has class
if(document.getElementById("myElmentID").classList.contains("hidden")){
}
Example 2: jquery check if a class exists
if ($(".mydivclass")[0]){
} else {
}
Example 3: jquery hasclass
$( "#mydiv" ).hasClass( "foo" )
Example 4: if a class exists jquery
if ($(".mydivclass").length){
} else {
}
Example 5: button has class or not c#
if(el.getAttribute("class").split(" ").contains("disabled"))
{
}
or
#region HTML Method
public static bool hasClass(WebControl element, string strClass)
{
return Convert.ToString(element.Attributes["class"]).Split(' ').Contains(strClass);
}
#endregion