Q:

if else statement that checks if div class excist or not

Jquery
html
i want an if else statement wich checks if the class .post-single excists 
and then if excist execute code:
single = $('.post-single').height();
tab = $('#tab');
tab_height = tab.height();
footer_height = $('footer').height();
max_top = (single + 323) - (tab_height);
tab_offset = tab.offset();

and if not excist execute this the same code but a different class
single = $('.wrap content').height();
tab = $('#tab');
tab_height = tab.height();
footer_height = $('footer').height();
max_top = (single + 323) - (tab_height);
tab_offset = tab.offset();

A:

Try to use the element's length property to check its presence,
if($('.post-single').length) {
 //exist
}
else {
 //not exist
}

Full code,
single =($('.post-single').length) ? $('.post-single').height() : $('.wrap content').height();  
tab = $('#tab');
tab_height = tab.height();
footer_height = $('footer').height();
max_top = (single + 323) - (tab_height);
tab_offset = tab.offset();

