$(".List a").mouseenter(function(){
t=setTimeout("$.qhimg($(this))",2000)
  }).mouseleave(function(){
 clearTimeout(t);
});
$.qhimg=function($obj){
$obj.addClass("Active");
}
$(this) 好像无法跨函数,想传递过去,不知道怎么实现,试了好多种方式都不行,有高手能讲解下么
我想延时执行一段代码,请高手讲解

解决方案 »

  1.   

    var thisType=$(this);传的时候传thisType试试。
      

  2.   

    $(".List a").mouseenter(function(){
    t=setTimeout("$.qhimg('.List a')",2000)
      }).mouseleave(function(){
    clearTimeout(t);
    });
    $.qhimg=function(o){
    $(o).addClass("Active");
    }
     
    你想法太多了。
      

  3.   

    晕,是我没看明白。原来是一组对象中的某一个。var theforever_csdn;
    $(".List a").mouseenter(function(){
    theforever_csdn=$(this);
    t=setTimeout("$.qhimg()",2000)
      }).mouseleave(function(){
    clearTimeout(t);
    });
    $.qhimg=function(o){
    theforever_csdn.addClass("Active");
    }
      

  4.   

    另外你也可以传递this.index过去,然后在$.qhimg里用eq(n)找到对应项。
      

  5.   

    $(".List a").mouseenter(function(){
        var _that=$(this);
        t=setTimeout(function(){
            $.qhimg(_that)
        },2000)
    }).mouseleave(function(){
        clearTimeout(t);
    });$.qhimg=function($obj){
        $obj.addClass("Active");
    }
      

  6.   

    你传过去的$(this)应该是window对象了,你先把$(this)保存为一个变量,把变量传过去吧。$(".List a").mouseenter(function(){
    var _this = $(this);
    t=setTimeout("$.qhimg(_this)",2000)
       }).mouseleave(function(){
    clearTimeout(t);
    });
    $.qhimg=function($obj){
    $obj.addClass("Active");
    }