jQuery 延迟淡入效果
我只是想对此片段做两个简单的调整:
$(document).ready(function() {
$("span#poweroff a").click(function() {
$("body").append('<div class="overlay"></div>');
});
});
首先,我希望 body.append 操作随着时间的推移而发生。这只是一个遮光叠加,但我想淡入?
其次,当有人悬停“span#poweroff a”时,我希望在一段时间后显示“span#poweroff a .message”,也可以淡入。
任何大师都愿意拯救我,我能在很长一段时间内得到什么时间让我不断尝试和犯错并让我恢复正常?非常感谢!
I'm just trying to do two simple adjutments to this snippet:
$(document).ready(function() {
$("span#poweroff a").click(function() {
$("body").append('<div class="overlay"></div>');
});
});
First I would like the body.append action to happen over time. It's just a blackout overlay, but I would like to fade in?
Second when someone hovers "span#poweroff a" I would like, after a certain amount of time to show "span#poweroff a .message", also by fadeing in.
Any guru's out there willing to save me what could me quite a long time putzing with trial and error and set me straight? Would very much appreciate it!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
.delay()
。这可能就是您正在寻找的。至于您的代码,以下是您可能正在寻找的功能:这将作为一个粗略的框架(没有保证,因为我因犯小错误而臭名昭著)。
祝你好运!
Try
.delay()
. It's probably what you're looking for. As for your code, here are the functions you're probably looking for:This would work as a rough framework (no guarantees, as I am notorious for making small mistakes).
Good luck!
您需要像这样对覆盖 div 进行硬编码:
然后像这样使用 jQuery:
如果我理解正确的话,当有人单击 span#poweroff 时,它会慢慢显示覆盖 div。
我的问题是会发生什么当您将鼠标悬停在 span#poweroff a 上然后单击它并显示 .overlay 时?如果您单击它,它将激活延迟显示,因为您必须将鼠标悬停在它上面才能单击它。
如果我们需要等待覆盖层可见,这里是没有处理的 jQuery:
You need to hard code the overlay div like this:
Then the jQuery like so:
If I'm understanding you correctly, when someone clicks on span#poweroff it will slowly show the overlay div.
My question to you is what happens when you mouse over the span#poweroff a before clicking on it and showing the .overlay? If you go to click on it its going to activate the delayed show because you have to hover over it to click on it.
Here is the jQuery without handling if we need to wait for the overlay to be visible: