setTimeout立即触发

时间:2017-06-19 18:56:08

标签: javascript settimeout

zfade立即触发 - 任何想法我做错了什么?

$('.country_holder').hover(
          function(zfade) { 
                  $('.gallery_img').css('z-index','999'); 
          },
          function() {
                  $('.gallery_img').css('z-index','99'); 
          });

  setTimeout(zfade, 10000); 

编辑以包含CSS / html。

Jsfiddle简写:https://jsfiddle.net/5Lkz4sef/

Jsfiddle longhand:https://jsfiddle.net/5Lkz4sef/2/

1 个答案:

答案 0 :(得分:2)

您需要在使用之前定义该功能

var zfadeIn = function() { 
    $('.gallery_img').css('z-index','999'); 
};
var zfadeOut = function() {
    $('.gallery_img').css('z-index','99'); 
};

$('.country_holder').hover(zfadeIn,zfadeOut);

setTimeout(zfadeIn, 10000);