gpt4 book ai didi

jquery - 简单的淡入 jQuery

转载 作者:行者123 更新时间:2023-12-01 07:39:31 24 4
gpt4 key购买 nike

我正在尝试使用 jQuery 制作一个简单的 fadeIn fadeOut,但它似乎不起作用..

$("h1").append("<p>This is new.</p>");

// With the element initially hidden, we can show it slowly:
$("#clickme").click(function() {
$("#square").fadeIn("slow", function() {
// Animation complete
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="clickme">
Click me
</div>
<img id="square" src="https://cdn.glitch.com/4963558f-bbaf-419b-9695-abdd14691841%2Fsquare.png?1544000277571" alt="" width="100" height="123">

我从 http://api.jquery.com/fadein/ 得到这个(我用方形图像替换了书籍图像,因为我没有书籍图像)

我正在开始使用 JavaScript 和 HTML,但我并不真正理解其他 fadeIn jQuery 问题的答案,这就是我问自己的问题的原因。

最佳答案

您应该从#squaredisplay:none开始,然后您可以fadeIn

$("h1").append("<p>This is new.</p>");

// With the element initially hidden, we can show it slowly:
$( "#clickme" ).click(function() {
$( "#square" ).fadeIn( "slow", function() {
// Animation complete
});
});
#square {display:none}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="clickme">
Click me
</div>
<img id="square" src="https://cdn.glitch.com/4963558f-bbaf-419b-9695-abdd14691841%2Fsquare.png?1544000277571" alt="" width="100" height="123">

关于jquery - 简单的淡入 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53628877/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com