显示的 Jquery 中使用的淡入淡出效果不起作用,为什么?
$(function() {
$(document).ready(function() {
$('.Game').fadeIn(500);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="text">
<h1 class="Game">Darkness Island</h1>
<h2>Available soon</h2>
<button class="Download">Download</button>
<button class="Details">See details</button>
</div>
出了什么问题?
最佳答案
首先在“Game”div 上添加 display: none;
。
同时将 script 标记保留在 html 末尾
$(document).ready(function () {
$('.Game').fadeIn(500);
});
最重要的是,在 head 标签中包含 jquery。
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<div class="text">
<h1 class="Game" style="display: none;">Darkness Island</h1>
<h2>Available soon</h2>
<button class="Download">Download</button>
<button class="Details">See details</button>
</div>
<script>
$(document).ready(function () {
$('.Game').fadeIn(500);
});
</script>
关于javascript - 文档就绪时淡入淡出效果不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50786616/