将hoverintent添加到这个jquery片段中
Add hoverintent to this jquery snippet
是否有办法添加悬停到这个jquery片段?目前,如果你将鼠标悬停在带有"wall-block-content"类的周围元素上,它们都会淡入/淡出。
$(".wall-block-content").fadeTo("fast", 0);
$(".wall-block-content").hover(function(){
$(this).fadeTo("fast", 1);
},function(){
$(this).fadeTo("fast", 0);
});
使用计时器来实现意图:http://jsfiddle.net/bxqTr/
$(".wall-block-content").hover(function(){
var $this = $(this),
timer = $this.data("timer");
if(timer) window.clearTimeout(timer);
timer = window.setTimeout(function () {
$this.stop().animate({'opacity':'0'},100);
}, 1000);
$this.data("timer", timer);
},function(){
var $this = $(this),
timer = $this.data("timer");
if(timer) window.clearTimeout(timer);
$this.stop().animate({'opacity':'1'},100);
});
在这个例子中,用户必须在元素上停留至少1秒(1000毫秒)来显示意图。Barlas是对的,使用animate更简洁。
使用animate()方法代替,这样更可靠,您可以像这样改进您的动画:
Update:你可以创建一个带有透明bg的假元素,然后用它来触发目标元素的动画。
$(".hidden").hover(function(){
$('.target').stop().animate({'opacity':'1','margin-top':'0px'},100);
},function(){
$('.target').stop().animate({'opacity':'0','margin-top':'20px'},100);
});
<div id="wrapper">
<div class="target posi"></div>
<div class="hidden posi"></div>
</div>
#wrapper { position:relative; left:0; top:0; }
.posi { position:absolute; left:100px; top:100px; width:200px; height:200px;}
.hidden { background:transparent; cursor:pointer; }
.target {background:red; opacity:0;}
相关文章:
- 使用Javascript/jQuery以编程方式将当前锚点/哈希/片段附加到任何表单操作url
- 为什么这个jquery片段不起作用
- fadeIn, fadeOut jQuery 代码片段
- 使用Jquery.load()函数获取变量和页面片段
- jQuery - 数字格式的小片段无法按预期工作
- 使用 URL 片段来确定运行哪个 jquery 函数
- jQuery:这个简单的片段是如何工作的(下拉菜单)
- jQuery跨标签突出显示元素中的文本片段
- 让 html5 音频片段与 jQuery 的悬停产生共鸣
- 如何将 fadeOut jQuery 属性与 Javascript 文本片段一起使用
- 代码片段,使用jquery,我什至需要javascript吗?
- 一个简单的jquery片段来验证用户'的电子邮件地址
- 此javascript/jquery片段破坏了Internet Explorer兼容性
- 从这个jQuery片段创建一个Javascript函数
- 单击一个对象并显示另一个简单的jQuery片段
- 如何使一个Jquery片段只适用于某些特定的标签
- 如何将jQuery片段放入全局文件中
- 优化收入跟踪jQuery片段
- 将hoverintent添加到这个jquery片段中
- 了解关于Map()的Jquery片段