MediaWiki:Common.js: Difference between revisions
(Created page with "→Any JavaScript here will be loaded for all users on every page load.: <script type="text/javascript"> $('body').prepend('<a href="#" class="back-to-top">Back to Top</a>...") |
No edit summary |
||
| Line 13: | Line 13: | ||
$('a.back-to-top').fadeOut('slow'); | $('a.back-to-top').fadeOut('slow'); | ||
} | } | ||
}); | |||
$('a.back-to-top').click(function() { | |||
$('body, html').animate({ | |||
scrollTop: 0 | |||
}, 700); | |||
return false; | |||
}); | }); | ||
Revision as of 08:35, 1 September 2015
/* Any JavaScript here will be loaded for all users on every page load. */
<script type="text/javascript">
$('body').prepend('<a href="#" class="back-to-top">Back to Top</a>');
</script>
var amountScrolled = 300;
$(window).scroll(function() {
if ( $(window).scrollTop() > amountScrolled ) {
$('a.back-to-top').fadeIn('slow');
} else {
$('a.back-to-top').fadeOut('slow');
}
});
$('a.back-to-top').click(function() {
$('body, html').animate({
scrollTop: 0
}, 700);
return false;
});