我已经在我的一些脚本中添加了“异步”(见下文),但是我的返回顶部链接脚本现在不显示或不起作用。任何想法,因为我不太了解 JavaScript 并且我似乎找不到答案?下面是位于正文底部的代码:
<div class="sprite topsite active" style="display: none;">
<a href="#nav">Back to top arrow</a>
</div>
<script async src="content/js/hideaddressbar.min.js"></script>
<script async src="content/js/respond.min.js"></script>
<script async type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script async src="content/js/picturefill.min.js"></script>
<!-- back to top link -->
<script>
$(document).ready(function() {
// Show or hide the sticky footer button
$(window).scroll(function() {
if ($(this).scrollTop() > 200) {
$('.topsite').fadeIn(500);
} else {
$('.topsite').fadeOut(300);
}
});
// Animate the scroll to top
$('.topsite').click(function(event) {
event.preventDefault();
$('html, body').animate({scrollTop: 0}, 300);
})
});
</script>
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激,谢谢!