- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想要实现的目标:
鼠标悬停时 - 将显示共享图标。
单击共享图标时,将显示新 Div
问题
当鼠标移出共享图标时“新 Div 不应关闭,必须显示”。
当大图像的 MouseOut 完成时“新 Div 必须隐藏”
HTML:
<div class="article_videos_item clrfix">
<div class="article_videos_item_img">
<span class="field-content">
<a href="#">
<img typeof="foaf:Image" src="http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg" width="340" height="226">
<div class="socialIconsWrap">
<div class="social__sharing__icon"> Click Me
<div class="social__sharing__content">
On MouseOut of Share Icon, still i have to be shown
</div>
</div>
</div>
</a>
</span>
</div>
</div>
<h2 style="display:block; border:2px solid; padding:5px; float:left">
What Iam trying to Achieve : <br/>
#1. On Mouse Hover - Share Icon will be displayed. <br/>
#2. On Click of Share Icon, New Div will be Shown
<br/>
<b>Issue</b>
<br/>
When MouseOut on Share Icon "New Div should not close, it has to be displayed" .
<br/>
When the MouseOut is Done for Big Image "New Div has to Hide"
</h2>
JS:
$(function(){
gwt__features.init();
});
var social__hover__select = $('.article_videos_item .article_videos_item_img'),
social__sharing__icon = $('.socialIconsWrap .social__sharing__icon'),
social__sharing__content = $('.social__sharing__content');
var gwt__features = ({
social__icons : function(){
},
social__hover : function(){
$(social__hover__select).on('mouseover',function(){
$(social__sharing__icon).show();
});
},
social__out : function(){
$(social__hover__select).on('mouseout',function(){
$(social__sharing__icon).hide();
$(social__sharing__content).hide();
});
},
social__click : function(){
$(social__sharing__icon).on('click',function(e){
e.preventDefault();
e.stopPropagation();
$(social__sharing__content).show();
});
},
init : function(){
this.social__icons(),
this.social__hover(),
this.social__out(),
this.social__click();
}
});
感谢您的帮助!
最佳答案
我已经在代码中实现了一个新条件。如果单击该图标,则 newDiv 将设置为 1 并且将显示 newDiv。如果没有点击该图标,则不会创建 newDiv。
$(function(){
gwt__features.init();
});
var social__hover__select = $('.article_videos_item .article_videos_item_img'),
social__sharing__icon = $('.socialIconsWrap .social__sharing__icon'),
social__sharing__content = $('.social__sharing__content');
var newDiv = 0;
var gwt__features = ({
social__icons : function(){
},
social__hover : function(){
$(social__hover__select).on('mouseover',function(){
$(social__sharing__icon).show();
});
},
social__out : function(){
$(social__hover__select).on('mouseout',function(){
if(newDiv == 0){
$(social__sharing__icon).hide();
$(social__sharing__content).hide();
} else {
$(social__sharing__icon).hide();
$(social__sharing__content).show();
}
});
},
social__click : function(){
$(social__sharing__icon).on('click',function(e){
e.preventDefault();
e.stopPropagation();
$(social__sharing__content).show();
newDiv = 1;
if( newDiv == 1){
$(social__sharing__content).show();
}
});
},
init : function(){
this.social__icons(),
this.social__hover(),
this.social__out(),
this.social__click();
}
});
如果有任何需要改进的地方,请告诉我。
关于javascript - jQuery 冒泡 - MouseOut 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28426564/
例如,如果我执行 $('div#something').mouseout(function(){}); ,那么当我将鼠标悬停在 #something 内的文本上时,该函数将会触发div 而不是当我离开
我有一个输入,当有人将鼠标悬停在输入上时,我希望它的 BGcolor 变为灰色,然后当他们悬停在输入上时,我希望它的 BGcolor 变回白色(默认颜色)。但我也希望输入的 BGcolor 在输入焦点
所以我有一个分配鼠标悬停的函数,这会向触发它的 div 添加一个悬停工具提示 div 和一个 mouseout 事件,以便我可以删除工具提示。 问题是 mouseout 事件会触发,但当我将鼠标移动到
我有一个鼠标悬停/鼠标悬停处理程序。两者都使用 JavaScript 超时来延迟他们的工作。但即使鼠标仍在选择器上,也会触发 mouseout 事件。当在 mouseout 脚本中关闭超时时,它可以正
我正在为一些悬停时的 div 创建自定义动画。像这样: $('.d1').on('mouseover', function () { $('.d2').animate({ 'margin-top'
大家好,我的任务是为我们的网站构建一个 slider 。这是我的目标: ... 当一个按钮悬停在上方时,我需要将“ slider ”向左移动 30 像素,当另一个按钮悬停在上方时,需要向右移动
奇怪的是当鼠标光标越过子节点时会触发 mouseout 事件。为什么光标还没有离开父节点会出现这种情况呢?请考虑这一点: function someFunc(obj) {
我正在尝试在 div 的鼠标移出时触发一个函数。但是,当您将鼠标悬停在 div 中的某个元素上时,它会触发鼠标移出。 X $("#my_div").mouseout(function (
See issue here 当我将鼠标悬停在图像上时,它会缩放,但当我将鼠标悬停在标题上时,缩放会重置。它就像绝对定位的元素注册了一个 mouseout。 .tint { overflow:
大家晚上好我不知何故陷入了一个简单的问题,但无法弄清楚如何解决它。我是第一次玩 jquery。 现在在 mousenter 上它可以很好地播放音频文件,但我试图实现一个 on mouseout 函数来
我有一些 CSS3 悬停效果来为图像标题设置动画: .imageDetails { width: 100%; height: 360px; position: absolute
我正在使用 JavaScript 来隐藏图像并显示隐藏在图像下的一些文本。但是,当您滚动显示文本时,它会在容器上触发 mouseout 事件,然后隐藏文本并再次显示图像,然后它就进入了一个奇怪的循环。
我想在 3D 转换的 Canvas 上绘图,但在 Chrome 中的 mouseout 事件有一些奇怪的问题。 当我将 JSFiddle 窗口大小设置为 2100px 时,mouseout 事件作为异
我怎么能有两张图片,一张在鼠标悬停时显示,一张在鼠标移出时隐藏? my box" function showIt(imgsrc) { document.get
以下函数会在鼠标悬停时在图库上方打开一个框。问题是它不会停止尝试打开和关闭。这与鼠标在图片周围移动时触发 mouseout 函数有关。 真让人气愤。有解决这个问题的想法吗? $(document).r
我有一个显示为none的div,我想当鼠标移到另一个div上时将其淡入,并在鼠标离开该div时将其淡出。问题是,一旦我查看了 div,无论鼠标是打开还是关闭,div 都会淡入和淡出大约 10 次。大家
我有 SVG 圆圈和文本元素,当鼠标悬停在...上时它们会改变颜色 var texts = svgcontainer.selectAll('text.year') .data(yeardata).en
我在页面中有一个菜单,我有一个事件类应用于与页面相关的相关菜单项。 当另一个菜单项悬停在上方时,此事件类将被重用,并从原始菜单项中删除。 如何制作菜单当我从#menu .mouseout 时刷新? 最
我正在开发一个 slider ,当鼠标悬停在 Logo 上时,详细信息将显示,而当鼠标悬停在其父 div 上时,它应该隐藏。 jQuery('.st_inner img').mouseover(fun
我在 FireFox 和 IE 11 中遇到了 mouseout 事件的问题。我已经在许多不同的设置上使用 browserstack 测试了该功能,但它表明该功能在 Chrome、Safari、Ope
我是一名优秀的程序员,十分优秀!