jQuery淡入/输出确认文本
我在页面上有一个div,默认情况下是空的(和/或隐藏的),以及应该在不同操作后的确认文本打印一会儿,然后消失。
我想和jQuery一起做这件事,但陷入了褪色。
我使用了此代码:
< div id ='确认'样式='display:none'></div>
$('#crescentation').html(“<字体color ='green'>成功
!文字进入此Div。即使在文本更改后,它仍然继续尝试淡入前一个,然后再次淡入。
我希望它的行为是这样的:当发送几个确认时,它们之间的延迟几乎应该停止执行当前序列并从头开始启动(立即淡出,立即更改文本,然后慢慢褪色)。
同样,对于初始“显示:无”,第一个序列的行为也有所不同。
您能建议某种方法来实现我想要的东西吗?
I have a div on the page which is empty (and/or hidden) by default and where a confirmation text after different actions is supposed to be printed out for a while and then disappear.
I wanted to do this with jquery but got stuck with fading in and out.
I used this code:
<div id='confirmation' style='display:none'></div>
$('#confirmation').html("<font color='green'>Success!</font>").fadeIn(300).delay(3000).fadeOut(300);
It kinda works but everything gets broken when the page sends several confirmation texts into this div. It still continues to try to fadeOut the previous one even after text has changed and then fades it In again.
I wanted it to behave like this: when several confirmations are being send with little delay between them it should stop executing the current sequence and start it from scratch (fade out instantly, change the text and then fade in slowly).
Also with initial 'display:none' the first sequence behaves differently.
Can you advise some way to achieve what I want?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用jQuery .stop()。可能是您需要更改它们的位置以创建完美的序列,但我希望您明白这个想法。 ✌️
编辑:忘了添加Clearqueue true命令。您可以在
You can use jQuery .stop() for that. Can be that you need to change the location of them to create the perfect sequence but I hope you get the idea. ✌️
Edit: forgot to add clearQueue true command. You can find more intel on https://api.jquery.com/stop/