悬停效果产生闪烁
hover effect creates flickering
我试图在悬停的图像上显示选项,但是当我悬停时显示的选项一直闪烁
$('a').hover(function(event) {
var href = $(this).attr('href');
var top = $(this).next().css("bottom");
$(this).next().css("display", "block");
$(this).next().next().css({ 'top': '30px', 'display': 'block' });
},function() {
$(this).next().hide();
$(this).next().next().hide();
});
});
$('.SelectionAnimate').hover(function() { $(this).css("display", "block"); $(this).next().show(); });
listview代码
<ItemTemplate>
<div style="float: left; position: relative; margin: 10px;" >
<div>
<a class="real" href='<%#"/ProfileTenModified/UserProfile/PhotoCross.aspx?in="+ Eval("Full_Image_Name") +"&mi=" + Eval("User_Id") +"&fd="+ Eval("Album")%>'>
<asp:Image ID="Image1" runat="server" ImageUrl='<%#"/ProfileTenModified/setP/"+ Eval("Slide_Thumb_Name") +".JPEG" %>'
BorderStyle="Solid" BorderWidth="1px" Width="172px" Height="172px" />
</a>
<asp:LinkButton CssClass="SelectionAnimate" ID="Selection" runat="server" Text="Set as Display"
OnCommand="ListViewThums_Selection_Command" CommandName="selection"></asp:LinkButton>
<asp:LinkButton CssClass="SelectionAnimate" ID="Deletion" runat="server" Text="Remove"
OnCommand="ListViewThumbs_Command"></asp:LinkButton>
</div>
<asp:HiddenField ID="HiddenFieldImageId" runat="server" Value='<%#Eval("Id") %>' />
</div>
</ItemTemplate>
我使用mouseenter
和hover
都创建相同的效果。有没有办法解决这个问题
只能在a
上应用.hover()
。因此,当你悬停a
,图像出现悬停a
,这意味着你不再悬停a
。这将触发.hover()
的第二次回调,图像将消失。然后你再次悬停a
,它会无限重复。
要解决这个问题,您只需将.hover()
绑定到父容器或两个元素上。
我曾经遇到过和你类似的问题。因此,为了解决这个问题,我使用了mouseenter和mouseleave事件。
$(selector).on('mouseenter', function(){
//perform what you want whe mouse is on your selector
}).on('mouseleave', function(){
//your code on when mouse leaves the selector
});
相关文章:
- 悬停时setInterval中的图像闪烁
- 悬停时损坏的CSS菜单 - 闪烁效果
- jQuery图像在悬停时闪烁
- Javascript拉斐尔奇怪的闪烁发生在我鼠标悬停的第三次
- 当我将鼠标悬停在iframe上时,DIV会闪烁
- 为什么jquery是悬停的,在下拉菜单上滑动功能闪烁
- 更改元素父元素的背景颜色时停止在
上闪烁鼠标悬停?jQuery/JS. - 当鼠标悬停在其上时,Div 会闪烁
- jQuery悬停气泡导致循环闪烁效果
- 在元素悬停时闪烁,同时尝试在同一事件上缩小其大小
- Bootstrap 3选项卡,活动选项卡仅在firefox中悬停时闪烁
- 在元素中使用mouseover和mouseout会使悬停持续闪烁
- jQuery悬停动画期间的最后一次潜水闪烁
- 谷歌地图-标记在鼠标悬停前闪烁
- 在悬停上添加边框会导致闪烁
- 悬停效果产生闪烁
- 鼠标悬停状态闪烁
- Jquery改变背景颜色悬停,不断闪烁
- jQuery覆盖悬停闪烁问题
- Javascript鼠标悬停元素闪烁;未捕获的类型错误