帮助解决此 JQuery 淡出和 in 语句

发布于 2024-10-09 10:45:13 字数 216 浏览 0 评论 0原文

我编写了这段代码,用于在单击链接时淡出一个元素并淡入一个新元素。它正在工作,但有点抽搐,有时它会在更改和位置移动之前闪烁...自己尝试一下,然后在链接之间来回单击...哦,我在 Firefox 中看到这些故障...

有看看这里。 http://jsfiddle.net/XHXpt/2/

I have this snippet of code I wrote for fading an element out and a new element in when a link is clicked. It is working but it is kind of twitchy and sometimes it flashes before the change and the position moves...Try it for yourself and click back and forth between the links...Oh I am seeing these glitches in firefox...

Have a look here. http://jsfiddle.net/XHXpt/2/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

百合的盛世恋 2024-10-16 10:45:13

它出现故障,因为已经隐藏的

元素立即完成其动画并调用您指定的complete回调。您可以通过仅淡入 :visible 来防止这种情况,因此那些已经隐藏的不做任何事情,通过更改此:

$('p').fadeOut('fast', function() {

对此:

$('p:visible').fadeOut('fast', function() {

您可以测试更新的版本在这里

It's glitching because the already hidden <p> elements finish their animations immediately and call the complete callback you specified. You can prevent this by fading only the :visible one, so those already-hidden ones don't do anything, by changing this:

$('p').fadeOut('fast', function() {

To this:

$('p:visible').fadeOut('fast', function() {

You can test out the updated version here.

时常饿 2024-10-16 10:45:13

添加:可见,如下所示: http://jsfiddle.net/XHXpt/5/

Add :visible as here : http://jsfiddle.net/XHXpt/5/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文