How can i check if css class exists on page and add new one to the body something like:

function mytheme_preprocess_html(&amp;$vars) {
  //if css.class exists on page{
  $vars['classes_array'][] = 'my-class';
 //}
}


... All i want is to add class to other elements if there is custom views (module:views) on my landing-page
function mytheme_preprocess_html(&amp;$vars) {
  $vars['classes_array'][] = 'new-class';
} 


or

if ($('body.mydivclass').length &gt; 0) {
  $('body').addClass('new-class');
}