MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
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(); | |||
} | |||
}); | |||
}); |
Revision as of 18:33, 12 April 2025
$(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();
}
});
});