jQuery(document).ready(function( $ ) { //Add Has Children to a UL that has children $('ul li:has(ul)').addClass('item-has-children'); //Equal Height Divs $('.equal-h').matchHeight(); // browser window scroll (in pixels) after which the "back to top" link is shown var offset = 300, //browser window scroll (in pixels) after which the "back to top" link opacity is reduced offset_opacity = 1200, //duration of the top scrolling animation (in ms) scroll_top_duration = 700, //grab the "back to top" link $back_to_top = $('.voom-top'); //hide or show the "back to top" link $(window).scroll(function(){ ( $(this).scrollTop() > offset ) ? $back_to_top.addClass('voom-is-visible') : $back_to_top.removeClass('voom-is-visible cd-fade-out'); if( $(this).scrollTop() > offset_opacity ) { $back_to_top.addClass('voom-fade-out'); } //console.log($(document).scrollTop()); }); //smooth scroll to top $back_to_top.on('click', function(event){ event.preventDefault(); $('body,html').animate({ scrollTop: 0 , }, scroll_top_duration ); }); });