if ($('#myDiv').length) $('#myDiv').show();
Source:
http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_test_whether_an_element_exists.3F
if ($('#myDiv').length) $('#myDiv').show();
Source:
http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_test_whether_an_element_exists.3F
Here is how to do this:
var offset = $('#OBJECT-ID').offset().top; $('html,body').animate({ scrollTop: offset }, 500);