1if ($( "#foo" ).hasClass('className')) {
2 $( "#foo" ).removeClass( 'className');
3} else {
4 $( "#foo" ).addClass( 'className');
5}
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