开发者

Setting jQuery Timeout on a div containing Flash

开发者 https://www.devze.com 2023-02-17 01:19 出处:网络
So, I need to remove a div once the flash has finished playing. I am using this so far (the first function is to show the flash div on hover, the 2nd to remove it.):

So, I need to remove a div once the flash has finished playing. I am using this so far (the first function is to show the flash div on hover, the 2nd to remove it.):

$(document).ready(function(){

        $(".showFlash").hover(function () {
          $("#flash").show("fast");
        });

    setTimeout(function() {
$('#flash').fadeOut('fast');}, 3000); // 
      });

It works fine the first time around. Though when I activate the flash again by hovering over the .showFlas开发者_如何学运维h element again - it doesn't work. Any ideas? Thanks.


No need to use timeout. Keep it simple

$(".showFlash").mouseenter(function () {
      $("#flash").show("fast").delay(3000).fadeOut('fast');
    });

Also I think you want to run this when mouse enters the .showFlash, not on hover (that triggers the event on enter and on exit)

0

精彩评论

暂无评论...
验证码 换一张
取 消