if a class exists jquery

Solutions on MaxInterview for if a class exists jquery by the best coders in the world

showing results for - "if a class exists jquery"
Eduardo
19 Jan 2020
1$("#EL_ID").hasClass("CLASS_NAME");
Domenico
10 Apr 2016
1if ($(".mydivclass").length){
2    // Do something if class exists
3} else {
4    // Do something if class does not exist
5}
Salvatore
03 Jun 2017
1if ($(".mydivclass")[0]){
2    // Do something if class exists
3} else {
4    // Do something if class does not exist
5}
Camilla
10 Aug 2020
1if ($(".mydivclass")[0]){
2    // Do something if class exists
3} else {
4    // Do something if class does not exist
5}
6
Maximiliano
04 Sep 2018
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
similar questions
queries leading to this page
if a class exists jquery