$(document).ready(function() { function buttonUp() { var valux = $('.ExpInput').val(); valux = $.trim(valux).length; if (valux !== 0) { $('.Expbtn').css('z-index', '99'); } else { $('.ExpInput').val(''); $('.Expbtn').css('z-index', '-999'); } } }); $(document).ready(function() { var submitIcon = $('.ExpIcon'); var submitInput = $('.ExpInput'); var searchBox = $('.Exp-serach'); var isOpen = false; $(document).mouseup(function() { if (isOpen == true) { submitInput.val(''); $('.Expbtn').css('z-index', '-999'); submitIcon.click(); } }); submitIcon.mouseup(function() { return false; }); searchBox.mouseup(function() { return false; }); submitIcon.click(function() { if (isOpen == false) { searchBox.addClass('Exp-serach-open'); isOpen = true; } else { searchBox.removeClass('Exp-serach-open'); isOpen = false; } }); }); $(document).ready(function() { $('a[href^="#"]').on('click', function(e) { e.preventDefault(); var target = this.hash; var $target = $(target); $('html, body').stop().animate({ 'scrollTop': $target.offset().top }, 100, 'swing', function() { // window.location.hash = target; }); }); }); // ===== Scroll to Top ==== $(window).scroll(function() { if ($(this).scrollTop() >= 50) { // If page is scrolled more than 50px $('#return-to-top').fadeIn(200); // Fade in the arrow } else { $('#return-to-top').fadeOut(200); // Else fade out the arrow } }); $('#return-to-top').click(function() { // When arrow is clicked $('body,html').animate({ scrollTop: 0 // Scroll to top of body }, 500); });