MediaWiki:Common.js: Difference between revisions
m Blanked the page Tag: Blanking |
mNo edit summary |
||
Line 1: | Line 1: | ||
$(function () { | |||
const $button = $('<div id="back-to-top">Back to Top ↑</div>'); | |||
$('body').append($button); | |||
$button.on('click', function () { | |||
$('html, body').animate({ scrollTop: 0 }, 500); | |||
}); | |||
$(window).on('scroll', function () { | |||
if ($(this).scrollTop() > 300) { | |||
$button.fadeIn(); | |||
} else { | |||
$button.fadeOut(); | |||
} | |||
}); | |||
}); |