$(window).resize(() => { const $t = $(window); if ($t.width() > 800 || $t.height() > 400) return; $('#div').show(); });