悬停上的 Jquery 字幕
我用 jQuery 编写了一个简单的脚本,允许根据 .hover 触发器弹出和弹出标题。
问题是您必须将鼠标悬停在图像上,移回,然后再次将鼠标悬停在图像上才能正常工作。 (你可以在这里明白我的意思http://jsfiddle.net/sambeckhamdesign/bqjqb/)
是这是 (document).ready()
部分的问题还是 jQuery 本身的问题?我真的看不出这里的问题,似乎太简单了,无法搞砸哈哈。
jQuery(document).ready(function() {
$(".projectImages li").hover(
function() {
$(this).find(".imageCaption").animate({
opacity: "show",
bottom: "0"
}, "fast");
},
function() {
$(this).find(".imageCaption").animate({
opacity: "hide",
bottom: "-50"
}, "fast");
});
});
I've written a simple script in jQuery that allows a caption to pop in and out based on the .hover trigger.
The problem is that you have to hover over the image, move back out then hover over it again before it works. (you can see what I mean here http://jsfiddle.net/sambeckhamdesign/bqjqb/)
Is it a problem with the (document).ready()
part or just a glitch in jQuery itself? I really can't see the problem here, seems too simple to mess up lol.
jQuery(document).ready(function() {
$(".projectImages li").hover(
function() {
$(this).find(".imageCaption").animate({
opacity: "show",
bottom: "0"
}, "fast");
},
function() {
$(this).find(".imageCaption").animate({
opacity: "hide",
bottom: "-50"
}, "fast");
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将图像标题类调整为
display:none;
。更改它应该定义元素在第一次悬停时处于正确的状态。由于元素的初始状态是阻止,因此鼠标输入从未被执行,因为它已经设置为阻止。
更新了 jsfiddle
Adjust your image caption class to
display:none;
. Changing that should define the element in the correct state for the first hover.Since your initial state of the element was block the mouse enter never was executed since it was already set to block..
Updated jsfiddle
尝试:
Try:
使用 jQuery 在页面加载时隐藏元素:
http://jsfiddle.net/FrelCee/bqjqb/33/< /a>
Use jQuery to hide element on page load :
http://jsfiddle.net/FrelCee/bqjqb/33/