/** * TO TOP */ $(window).scroll(function() { if ($(this).scrollTop() > 10) { $('#to-top').css({'transform':'translate3d(0,0,0)'}); } else { $('#to-top').css({'transform':'translate3d(60px,60px,0)'}); } }); Jq("#to-top").on('click', function(e) { e.preventDefault(); Jq('html, body').animate({scrollTop:0}, '300'); }); /** * HEIGHT bgRed */ checkBgRedHeight(); $(window).resize(checkBgRedHeight); function checkBgRedHeight(){ if(document.getElementsByClassName('bgGrey').length > 0){ var h = document.getElementsByClassName('bgGrey')[0].clientHeight+'px'; document.getElementsByClassName('bgRed')[0].style.height = h; } } /* * Scroll focus search */ $(document).ready(function (){ $(".boxRicercaNRE input").on("click", function(){ if ($(window).width() < 768) { $('html, body').animate({ scrollTop: $('.boxRicercaNRE').offset().top }, 800); } }); $("#scelta_punto_vendita_container input").on("click", function(){ if ($(window).width() < 768) { $('html, body').animate({ scrollTop: $('#scelta_punto_vendita_container').offset().top }, 800); } }); });