Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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