Jquery 切换鼠标事件?
嗨,伙计,我有一个鼠标悬停事件和鼠标悬停事件。这是正确的方法吗?还是有更好/更干净的方法 我做了一个演示 您可以改为使用: 将两个处理程序绑定到匹配的元素,在 鼠标指针进入和离开元素Jquery 切换鼠标事件?,jquery,Jquery,嗨,伙计,我有一个鼠标悬停事件和鼠标悬停事件。这是正确的方法吗?还是有更好/更干净的方法 我做了一个演示 您可以改为使用: 将两个处理程序绑定到匹配的元素,在 鼠标指针进入和离开元素 您可以使用悬停输入/输出处理程序: 或仅使用CSS: $(".containerslide").mouseover(function(){ $(this).find(".slide").stop().animate({'margin-left': '0',}, 500) }); $(".co
您可以使用
悬停
输入/输出处理程序:
或仅使用CSS:
$(".containerslide").mouseover(function(){
$(this).find(".slide").stop().animate({'margin-left': '0',}, 500)
});
$(".containerslide").mouseout(function(){
$(this).find(".slide").stop().animate({'margin-left': '-320px',}, 500)
});
$(".containerslide").hover(function () {
$(this).find(".slide").stop().animate({
'margin-left': '0',
}, 500)
}, function () {
$(this).find(".slide").stop().animate({
'margin-left': '-320px',
}, 500);
});
$(".containerslide").hover(function (e) {
$(this).find(".slide").stop().animate({
marginLeft: e.originalEvent.type === "mouseover" ? 0 : -320,
}, 500)
});
.slide {
margin-left:-320px;
position: absolute;
background: yellow;
width: 320px;
height: 250px;
-webkit-transition: margin-left .5s;
transition: margin-left .5s;
}
.containerslide:hover .slide{
margin-left:0;
-webkit-transition: margin-left .5s;
transition: margin-left .5s;
}