Jquery mouseover和mouseout问题

时间:2015-06-12 09:09:16

标签: javascript jquery

我正在为我的视频制作一个自定义播放暂停按钮。但是当我将鼠标悬停在按钮上时按钮会一直闪烁。当我将鼠标悬停在按钮上时,任何想法都会停止闪烁?谢谢



$('#fullplay')
    .mouseover(function () {
        $('#playpausevideo').fadeIn();
    })
    .mouseout(function () {
        $('#playpausevideo').fadeOut();
    });

.container{
  
  }

.playpausevideo{
    height:100px;
    width:100px;
    position:absolute;
    background-image:url('/../../Images/onbigplan/bigfullplay.png');
	background-repeat:no-repeat;
	background-position:center;
    cursor:pointer;
    display:none;
    background-color:#000;
    z-index:99999;
}
.playpausevideo.selected{
    height:100px;
    width:100px;
    position:absolute;
    background-image:url('/../../Images/onbigplan/bigfullpause.png');
	background-repeat:no-repeat;
	background-position:center;
    cursor:pointer;
    background-color:#ff0000;
    z-index:99999;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
  <div id="playpausevideo" class="playpausevideo noselected"></div>
<video id="fullplay" autoplay muted loop poster="" width="400px" height:="300px">
  <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
  <source src="http://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg" />
</video>

 </div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

您可以将视频和按钮打包成div,并在该div上收听mouseentermouseleave个事件。

这是一个jsfiddle示例:http://jsfiddle.net/jp5ru8vz/