//hover事件
$("a").hover(function(event){
$(this).css("color", "red");
},function(event){
$(this).css("color", "blue");
});
正常hover事件在某些时候会有局限性,可以改编成这样
$(this).css("color", "red");
},function(event){
$(this).css("color", "blue");
});
正常hover事件在某些时候会有局限性,可以改编成这样
第一种:切换式
$(document).on('mouseenter mouseleave',".tab_ul
>.row",function()
{
$(this).find("h3").toggleClass("zt_bh");
$(this).find(".more").toggleClass("zt_bh1");
$(this).find(".hx").stop().toggle().slow();
})
//data_center
$(document).on('mouseenter
mouseleave',".xz_down",function()
{
$(this).toggleClass("xa_bs");
$(this).find(".img1").toggle();
$(this).find(".img2").toggle();
$(this).find("em").toggleClass("xa_bs");
})
第二种:隐藏显现式
$('ul.course_lists
li').on({
mouseenter:function(){
$(this).css('border-color','#ccc');
},
mouseleave:function(){
$(this).css('border-color','#fff');
}
});
第三种:第一种的精确延伸
$(obj).on("mouseover
mouseout",function(event){
if(event.type
==
"mouseover"){//鼠标悬浮
}else
if(event.type ==
"mouseout"){//鼠标离开
}
})

本文介绍了一种改进的hover事件实现方法,通过三种不同的方式展示了如何利用jQuery来增强元素的悬停效果,包括切换样式、隐藏与显示内容等,适用于前端开发人员学习。
1万+

被折叠的 条评论
为什么被折叠?



