jquery check if class contains any element

Solutions on MaxInterview for jquery check if class contains any element by the best coders in the world

showing results for - "jquery check if class contains any element"
Naim
17 Jan 2017
1$("#EL_ID").hasClass("CLASS_NAME");
Grace
06 Jul 2018
1if ($(".mydivclass").length){
2    // Do something if class exists
3} else {
4    // Do something if class does not exist
5}
Giovanni
12 Mar 2019
1if ($(".mydivclass")[0]){
2    // Do something if class exists
3} else {
4    // Do something if class does not exist
5}
Lena
04 Jan 2019
1jQuery(function ($) {
2	if ($(".className").length == 0) {
3		$(".element").removeAttr("style").hide();
4	}else{
5		$(".element").removeAttr("style").show();
6	}	
7});
similar questions
queries leading to this page
jquery check if class contains any element