- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想要一个有 4 个边的悬停 slider ,其中当我将鼠标悬停在幻灯片上时,它的宽度会增大,而其他 3 个边的宽度会减小。我想出了这段代码:
$(document).ready(function(){
$('.hovermenu li').mouseenter(function(){
$(this).animate({width: "69%"},250);
$(this).parent().children('li').not(this).animate({width: "10%"},250);
});
$('.hovermenu li').mouseleave(function(){
$(this).animate({width: "25%"},250);
$(this).parent().children('li').not(this).animate({width: "25%"},250);
$(this).not('li').animate({width: "10%"},250);
});
});
但它有一个问题。当我将鼠标单独悬停在一张幻灯片上(不是从一张幻灯片迁移到另一张幻灯片)时,脚本似乎工作正常,但是当我将鼠标从一张幻灯片移动到另一张幻灯片时,4 张幻灯片的行为非常疯狂地继续改变它们的宽度一段时间,即使我把鼠标从幻灯片上移开。完整的 fiddle 在这里:http://jsfiddle.net/uprL2/1/
最佳答案
在开始新动画之前尝试使用 .stop(clearQueue)
清除动画队列,
$('.hovermenu li').mouseenter(function(){
$(this).stop().animate({width: "69%"},250);
$(this).parent().children('li').not(this).stop(true).animate({width: "10%"},250);
});
$('.hovermenu li').mouseleave(function(){
$(this).stop().animate({width: "25%"},250);
$(this).parent().children('li').not(this).stop(true).animate({width: "25%"},250);
});
当我们尝试将动画移至结束状态时,您的情况会出现问题,因此请尝试从 stop
函数调用中删除第二个参数。意思是要求函数不要跳到末尾。
关于jquery - 使用 mouseenter 和 mouseleave 悬停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24362815/
我对 mouseenter/mouseleave 函数有一些问题。 请看一下我的代码; $(".elms").live( { mouseenter: function (e) {
我在一个寻呼机中有一个顶部固定列表导航,工作正常。 我使用 jQuery 颜色插件添加了 mouseenter 和 mouseleave 颜色动画,效果也很好。 现在,如果单击链接,我想跳过 mous
我有一个指令在模板上显示学生信息列表,然后在鼠标输入时显示其他学生信息。我希望能够返回到 mouseleave 的初始状态。 尝试了所有资源,但运气不佳。 html - 这是我注入(inject)指令
我试图在鼠标输入鼠标离开事件时替换图像属性源。单击时,图像应保持事件状态。我需要 mouseleave 事件在单击后停止。到目前为止,点击后鼠标离开仍然继续,切换回图像,代码如下: jQue
我想要做的是创建一个下拉列表,当单击链接时该下拉列表会向下滑动,并根据单击的链接显示特定的隐藏 div。我希望它在单击另一个链接时在公开的下拉列表中的隐藏 div 之间优雅地切换。我们已经基本弄清楚了
有没有一种方法可以在拖动元素时检测鼠标离开? 我尝试拖放元素,如果它在视口(viewport)之外,则显示包含 div 元素的弹出窗口。 仅当我不拖动元素时才触发 mouseleave,但如果我尝试拖
如果我想鼠标进入一个div,就会显示一个元素,然后当鼠标离开时,元素就会消失。 我在 mouseenter 内有一个单击功能,因此单击时会出现一个下拉菜单。 我希望下拉菜单和元素即使在鼠标离开时也保持
所以,我的问题是只有当我以一定的速度移动光标时才会触发 MouseLeave 事件。下面是一个带有边框的拇指。单击拇指并按住鼠标按钮。缓慢移出边界 = 无事件,快速移出边界 = 事件。
我用 W3.CSS's slideshow documentation 创建了一个简单的幻灯片。您可以在这个 JS Fiddle上看到代码和幻灯片。 . 一切正常,除了在“mouseleave”事件发
鉴于下面显示的以下 html 表和脚本,我遇到了一个问题,即鼠标离开事件似乎在鼠标进入后立即触发,即使我没有将鼠标移出该行。 function highlightRows(iMainID)
嗨,我在下拉导航菜单上使用 mouseleave() ,这样当用户离开子菜单下拉菜单时,子菜单就会消失,但它似乎忽略了它,菜单仍然存在。有任何想法吗?这是网站和代码: http://www.maiag
http://jsfiddle.net/yZSEA/ $("p").hover(function() { var $this = $(this).find('span'); $this
HTML I'm div-1 I'm div-2 JS $("#div-1").bind('mouseover',function(event){ $('#div-2').stop(true,tr
抱歉,如果这看起来很基础,我是 JQuery 新手。 我的页面上有一个密码元素,我希望它能够在该框处于事件状态并且在框中键入时保持绿色,但 mouseleave 似乎优先于焦点。 这是该元素的代码:
example fiddle JavaScript $('#btn').on('mouseover', function() { $('#tt').show(); }).on('mousele
事情是这样的:我有一张 table 。当您将鼠标悬停在其上时,jQuery 会添加一些编辑按钮。当您将鼠标移出表格时,它们就会消失。问题是,如果您将鼠标移入表格,然后移到按钮上,然后移出,它们会保持在
我有像这样的菜单列表 第一个 ul 标记是从另一个框
我的表单上有一个上下文菜单,一些选项默认情况下应该禁用,但当用户右键单击面板时启用。 我写这个的方式,允许这个特定菜单项的面板有两个事件处理程序: MouseEnter -> 启用选项 MouseLe
我是 Jquery(和 JavaScript)的新手,我一直在尝试制作一个侧边栏,将鼠标悬停在图标上会显示它们各自的 div 元素(如果您愿意,可以称为“侧边栏”)。 我希望它的行为是这样的,只要您将
我试图在鼠标悬停在另一个 div 上时创建一个卷起的 div。它打开但我希望它在离开底部边框时不要关闭。是否可以使用 JS 或 JQuery?这是我当前的代码: $("#sell1").mouseen
我是一名优秀的程序员,十分优秀!