页面加载鼠标悬停是自动工作

时间:2014-10-31 09:17:41

标签: jquery css

当页面加载mouseover自动生效时,我遇到此问题

以下是cssjavascript

$('.divTop').mouseover(function(){
        $('.private').stop().animate({"top":"0px"},200);
        $('.corporate').stop().animate({"bottom":"0px"},200);
    });
    $('.private, .corporate').mouseout(function(){
        $('.private').stop().animate({top:"-50%"},200);
        $('.corporate').stop().animate({bottom:"-50%"},200);
    });
.private{
    background-image:url('/CapitalBank/img/icon/umbrella.png');
    /* border-bottom:1px solid #d2ab67; */
    background-size:50px;
    top:-50%;
}
.corporate{
    border-top:1px solid #d2ab67;
    background-image:url('/CapitalBank/img/icon/key.png');
    bottom:-50%;
}
.divTop{
    position:relative;
    float:left;
    width:500px;
    height:250px;
    /* outline:1px solid white; */
    background-image: url('/CapitalBank/img/bg/ibank.png');
    background-position:center;
    background-size:100% 100%;
}

1 个答案:

答案 0 :(得分:2)

$('.divTop').mouseenter(function(){
    $('.private').stop().animate({"top":"0px"},200);
    $('.corporate').stop().animate({"bottom":"0px"},200);
});
$('.private, .corporate').mouseleave(function(){
    $('.private').stop().animate({top:"-50%"},200);
    $('.corporate').stop().animate({bottom:"-50%"},200);
});
相关问题