jQuery 语法问题,我认为很简单
这个片段非常适合我的目的,唯一需要注意的是我需要 .module 悬停功能来同时向所有其他不是 $this 的“.caption”添加一类“under”,然后在悬停结束。所以基本上我不希望悬停的“模块”来获取类,我希望它完全按照我在这里显示的方式进行...在结束悬停时上下滑动 .caption,我只想要所有其他“.caption”。当任何“.module”悬停时,标题“s 获取下类。
我一直在尝试的事情陷入了死胡同,想用同样的功能来做。有什么想法吗?
$(document).ready(function() {
$(".module .caption").hide();
$(".module").hover(function() {
$(this).find(".caption").slideDown();
},function() {
$(this).find(".caption").slideUp();
});
});
This snippet works great for my purposes, the only caveat is that I need the .module hover function to simultaneously add a class of "under" to all other ".caption"'s that are not $this, and then remove them when the hover ends. So basically I don't want the "module" that is hovered to get the class, I want it to do exactly what I am showing here...sliding .caption up and down on end hover, I just want all other ".caption"s to get the under class when any ".module" is hovered.
Just hitting a dead end with what I have been trying, want to do it in the same function. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据你的 html 结构,类似这样的事情可能会做到这一点:
Depending on your html structure something like this might do it:
只需将该类添加到所有其他标题中,然后将其从匹配的标题中删除即可。在悬停结束时,只需将其从所有这些中删除即可。
Just add the class to all other captions, and then remove it from the matched caption. At the end of the hover just remove it from all of them.
我不确定这是否有帮助,因为我不知道“under”类到底是做什么的。
I'm not sure if this will help as i don't know what the "under" class does exactly.