mouseleave div,将背景颜色更改为灰色,mouseleave到div内触发Qtip,将背景颜色更改为粉红色
标题是不言自明的,这是我到目前为止所拥有的,但是背景颜色在鼠标移开时始终保持灰色,而不是在 qtip 悬停时保持粉红色:
$().ready(function() {
$("#openDiv").mouseleave(function (e) {
var used_classes = ['qtip'];
var $c = $(e.relatedTarget).attr('class');
if ($c=='qtip')
{
$("#openDiv").css('background-color', 'pink');
} else{
$("#openDiv").css('background-color', 'grey');
}
});
});
http://jsfiddle.net/bUzPG/21/ 完成设置。这让我发疯!
任何解决此问题的答案都将被标记为答案。
The title is self explanatory, here is what I have so far, but the background color always stays grey on mouseout, instead of pink on qtip hover:
$().ready(function() {
$("#openDiv").mouseleave(function (e) {
var used_classes = ['qtip'];
var $c = $(e.relatedTarget).attr('class');
if ($c=='qtip')
{
$("#openDiv").css('background-color', 'pink');
} else{
$("#openDiv").css('background-color', 'grey');
}
});
});
http://jsfiddle.net/bUzPG/21/ with complete setup. This is driving me crazy!
Any answer that solves this issue will be marked as the answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到的是,当鼠标离开 '#openDiv' 时,事件会触发,然后 e.latedTarget 将是您离开时输入的任何内容,这没什么。
如果你想要的是当鼠标悬停在 qtip 上时主 div 变成粉红色,你应该在 qtip 上使用 .hover (或 .mouseenter 将其设置为粉红色),就像简单的...
我看到 qtip 的东西似乎是在 DOM 准备好之后创建,所以你可能想使用 .live 来代替......
what I see is that the event fires when the mouse leaves '#openDiv' , and then e.relatedTarget would be whatever you're entering when you leave, which is nothing.
If what you want is for the main div to go pink when hovering over qtip, you should be using .hover (or .mouseenter to set it pink) on the qtip, like simply...
I see that the qtip thing seems to be created after the DOM ready, so you might want to use .live instead...