MediaWiki:Common.js: Difference between revisions

From Realm Of Thrones
Jump to navigation Jump to search
SitX (talk | contribs)
m Blanked the page
Tag: Blanking
SitX (talk | contribs)
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();
    }
  });
});