Check class or id exist or not by jQuery

 


//check class exist or not
if (jQuery(‘.element’).length) {
console.log(‘class exist’);
}else{
console.log(‘class not exist’);
}
//check id exist or not
if (jQuery(‘#element’).length) {
console.log(‘id exist’);
}else{
console.log(‘id not exist’);
}

Leave a Comment

Your email address will not be published. Required fields are marked *