jquery check class name code example
Example 1: jquery hasclass
if ($( "#foo" ).hasClass('className')) {
$( "#foo" ).removeClass( 'className');
} else {
$( "#foo" ).addClass( 'className');
}
Example 2: jquery check if a class exists
if ($(".mydivclass")[0]){
} else {
}
Example 3: if a class exists jquery
if ($(".mydivclass").length){
} else {
}
Example 4: jquery hasclass
jQuery(Selector).hasClass('class_name');
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