$(document).click(function (e) { var left = parseFloat($('.page').css("left")) if (!$(e.target).closest("#block-block-30, #top_menu_click").length && left ) $('#top_menu_click').click(); });