检查鼠标是否悬停在任何对象上
我有一个 jQuery 动画示例:http://jsfiddle.net/p7Eta/
如果鼠标根本不在容器 div 内,我希望弹出所有标题。我尝试做类似的事情:
$("#container").mouseout(
function() {
//slides spans up
$('.popup').stop().animate({
bottom: 0 + 'px'
});
});
但它不适用于之前的动画。达到这种效果的正确方法是什么?
编辑:我想要类似的东西:http://jsfiddle.net/RE3XK/ 但在鼠标悬停时,我希望像第一个示例中那样弹出各个跨度标题,而不是让它们全部消失
I have a jQuery animation example here: http://jsfiddle.net/p7Eta/
I would like all the titles to pop out if the mouse is not within the container div at all. I have tried to do something like:
$("#container").mouseout(
function() {
//slides spans up
$('.popup').stop().animate({
bottom: 0 + 'px'
});
});
But it does not work with the prior animations. What is the correct way to achieve this effect?
EDIT: I'd like something similar to this: http://jsfiddle.net/RE3XK/ but on mouseover I'd like the individual span titles to pop up like in the first example instead of having them all dissapear
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你的意思是这样的。
检查工作示例 http://jsfiddle.net/p7Eta/8/
更新
You mean like this.
Check working example http://jsfiddle.net/p7Eta/8/
Update
最后,jsFiddle 合作了......
我正在做一些 hacky 的事情,但这是我让它工作的唯一方法。我必须向当前悬停的元素添加一个
.hover
类,因为如果没有它,我的代码将无法正常工作。只要不看代码,它就会看起来很好!
这是一个工作示例: http://jsfiddle.net/p7Eta/41/
代码:
Finally, jsFiddle cooperated...
I'm doing something hacky, but it's the only way that I could get it to work. I had to add a
.hover
class to the currently hovered element, as my code doesn't work properly without it.Just don't look at the code, and it'll look nice!
Here's a working example: http://jsfiddle.net/p7Eta/41/
And the code:
我的猜测是,您正在寻找类似于这个的东西,对吗?我尝试的方式的唯一问题是您输入的元素也会向下滑动(我猜它不应该)。
My guess is that you're going for something along the lines of this one, am I right? The only issue with the way I tried it, is that the element you're entering on, also slides down (which it shouldn't, I guess).
或者类似的东西......它实际上在重置动画之前停止动画。 http://jsfiddle.net/NDtMW/
Or something like this... which actually stops the animations before resetting it. http://jsfiddle.net/NDtMW/
请澄清您的要求。您
顺便说一句,你的原始脚本只能在 IE 中运行。如果您只关心一种浏览器,请在以后说明。 IE 用户可能是 SO 上的少数。
Please clarify what you're asking for. Do you
BTW, your original script only works in IE. If you're only concerned with one browser, please say so in the future. IE users are probably the minority on SO.