Skip to content

Instantly share code, notes, and snippets.

@ocean90
Created December 4, 2011 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ocean90/1428560 to your computer and use it in GitHub Desktop.
Save ocean90/1428560 to your computer and use it in GitHub Desktop.
Click on the Admin Bar to scroll to top
<?php
function ds_admin_bar_scrolltop() {
if ( ! is_admin_bar_showing() )
return;
?>
<script>
( function( $ ) {
$( '#wpadminbar' ).click( function() {
$( 'html, body' ).animate( { scrollTop: 0 }, 100 );
} );
$( '#wpadminbar li' ).click( function( e ) {
e.stopPropagation();
} );
} )( jQuery );
</script>
<?php
}
add_action( 'admin_print_footer_scripts', 'ds_admin_bar_scrolltop' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment