写了个鼠标移入移出事件,有时无效

-一个大坑 2019-02-18 12:04:37

$('.backgroundButtonView').mousemove(function(){
$(this).css('background-color','#FFFFCC');
$(this).find('.backgroundCircleView').css('background-color','#0D6FA4');
}).mouseover(function(){
$(this).css('background-color','white');
$(this).find('.backgroundCircleView').css('background-color','#56BBEF');
})

鼠标移出后颜色变成原本颜色,经常移出时背景颜色没变,还是鼠标移入是改的那个颜色
...全文
544 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
小糖子先森 2019-02-19
  • 打赏
  • 举报
回复

.backgroundButtonView{
background-color:#FFFFCC;
}
.backgroundButtonView .backgroundCircleView{
background-color:#0D6FA4;
}
.backgroundButtonView:hover{
background-color:white;
}
.backgroundButtonView:hover .backgroundCircleView{
background-color:#56BBEF;
}


试试css吧 你那个事件有一个错了。
  • 打赏
  • 举报
回复
引用 楼主 -一个大坑的回复:

$('.backgroundButtonView').mousemove(function(){
$(this).css('background-color','#FFFFCC');
$(this).find('.backgroundCircleView').css('background-color','#0D6FA4');
}).mouseover(function(){
$(this).css('background-color','white');
$(this).find('.backgroundCircleView').css('background-color','#56BBEF');
})

鼠标移出后颜色变成原本颜色,经常移出时背景颜色没变,还是鼠标移入是改的那个颜色
我记得好像是mouseenter和mouseout
讨厌走开啦 2019-02-18
  • 打赏
  • 举报
回复 1
移入移出不应该是mouseenter和mouseleave吗?

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧