Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器 软件资源

软件开发小程序制作系统集成与运维空间租用硬件开发视频监控技术咨询与支持——联系电话:0311-88999002/88999003

首页 / 脚本样式 / jQuery / css hover与jquery

css hover与jquery2011-01-30 blogjava Fingki.lihover是鼠标悬停css效果,但在一些浏览器如ie6中,只对<a href=""/>有效。

jQuery可以为我们解决这个问题:

jQuery提供的hover()

方法做为一个事件,不仅可以改变CSS样式的,还可以做其他动作;

非常类似于mouseover mouseout的组合。

代码如下:

$(function(){
$(".htest").hover(
function(){
$(this).css("cursor","pointer");
$(this).css("color","red");
$(this).css("position","relative");
$(this).css("top","2px");
$(this).css("left","2px");
},
function(){
$(this).css("cursor","pointer");
$(this).css("color","blue");
$(this).css("position","relative");
$(this).css("top","0px");
$(this).css("left","0px");
}
);
$(".mtest").mouseover(function(){
$(this).css("cursor","pointer");
$(this).css("color","red");
$(this).css("position","relative");
$(this).css("top","2px");
$(this).css("left","2px");
});
$(".mtest").mouseout(function(){
$(this).css("cursor","pointer");
$(this).css("color","blue");
$(this).css("position","relative");
$(this).css("top","0px");
$(this).css("left","0px");
});
});