我有一张图片 - 点击后会显示两个子div,然后在鼠标离开时隐藏它们。
这只能连续工作两次,然后停止点击。
$('.art').click(function(){
var $this = $(this)
$this.children('.details').children('div').eq(1).show("slide", {direction: "left", easing: "easeOutQuad"}, 200);
$this.children('.details').children('div').eq(0).show("slide", {direction: "right", easing: "easeOutQuad"}, 200);
$this.bind("mouseleave", function(){
$this.children('.details').children('div').eq(0).hide("slide", {direction: "left", easing: "easeOutQuad"}, 200);
$this.children('.details').children('div').eq(1).hide("slide", {direction: "right", easing: "easeOutQuad"}, 200);
})
});
答案 0 :(得分:1)
每次单击带有.art
类的元素时,都会绑定到mouseleave。你能告诉我这是否有所改善:
$('.art').click(function(){
var $this = $(this);
$this.children('.details').children('div').eq(1).show("slide", {direction: "left", easing: "easeOutQuad"}, 200);
$this.children('.details').children('div').eq(0).show("slide", {direction: "right", easing: "easeOutQuad"}, 200);
});
$('.art').mouseleave(function(){
var $this = $(this)
$this.children('.details').children('div').eq(0).hide("slide", {direction: "left", easing: "easeOutQuad"}, 200);
$this.children('.details').children('div').eq(1).hide("slide", {direction: "right", easing: "easeOutQuad"}, 200);
})