gpt4 book ai didi

javascript - 隐藏 10 秒

转载 作者:搜寻专家 更新时间:2023-11-01 05:09:17 25 4
gpt4 key购买 nike

我正在做一个小脚本,元素应该只消失 2 秒,然后返回单独出现,我把链接留在这里 Fiddle

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('img').click(function() {
$(this).fadeOut();
setTimeout(function() {
$(this).fadeIn();

}, 1000);
//$(this).toggle();
});
});
</script>

我正在尝试使用淡入淡出和设置时间但它不起作用

最佳答案

$(this).fadeIn(); 上的 this 不再指向图像。

试试这个:

 $(document).ready(function() {
$('img').click(function() {
var img = this; /* Store it on variable img */
$(img).fadeOut();
setTimeout(function() {
$(img).fadeIn(); /* Can access variable img here */
}, 1000);
//$(this).toggle();
});
});

fiddle :https://jsfiddle.net/7rfypomx/1/

关于javascript - 隐藏 10 秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48278036/

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