(function( $ ) { if( $ == undefined ) { return; } var html_object; var button; $(document).ready( function() { html_object = $(window); append_button(); button = $('#scrollup_button'); $('#scrollup_button').click( function() { html_object.scrollTop( 0 ); html_object.trigger( 'scroll' ); } ); $(window).bind( 'scroll', function() { if( html_object.scrollTop() > 100 ) { button.removeClass( 'scrl_disabled' ); } else { button.addClass( 'scrl_disabled' ); } } ); $(window).bind( 'resize', function() { $('#scrollup_button').css( 'top', top_calc() ); }); } ); function append_button() { $('body').append( '
' ); $('#scrollup_button').css( 'top', top_calc() ); } function top_calc() { return ( $(window).height() ) - 75; } })(jQuery);