removeClass('d-sm-none'); containerSchovat.removeClass(' d-lg-block'); } if (!containerSchovat2.is(e.target) && containerSchovat2.has(e.target).length === 0) { containerSchovat2.removeClass(' d-lg-block'); } }); $('#search').on('click',function (){ var nas = $('.naseptavac') ; var inp = $(this); if($(this).val().length == 0 && (window.matchMedia('(min-width: 992px)').matches)) { nas.removeClass('d-none'); nas.addClass('d-sm-none'); nas.addClass(' d-lg-block'); var pozice = inp.offset(); nas.css({ 'top': pozice.top + inp.outerHeight() + 'px', 'left': pozice.left + 'px', 'position': 'absolute', 'width': inp.outerWidth() }); } }); // $('#search').click(); });