function over(id){
var h = parseInt(id.height);
if (h < 164){
tr.height = h + 2;
}
}
想用setTimeout调用那个函数该怎样写

解决方案 »

  1.   

    刚刚以为好了,是错觉的,是要把id传进去的,但是怎么试都不行的。setTimeout('over(id)',2)这样也不行的。
      

  2.   

    setTimeout只能是函数名...........
      

  3.   


    setTimeout('over',1000)
    function over(id){
    var h = parseInt(id.height);
    if (h < 164){
    tr.height = h + 2;
    }
    }setTimeout中只要写你需要调用的函数名就可以了,不用给函数写参数
      

  4.   

    但是那样的话id没有传,那我怎么获取id的值呢。
      

  5.   


    function over(id){
    var h = parseInt(id.height);
    if (h < 164){
    tr.height = h + 2;
    }
    }
    var SendYourId ="你的Id";//SendYourId是你的id 不是字符串
    setTimeout((function(GetYourId){over(GetYourId)})(SendYourId),1000);
      

  6.   

    如果上面不行就 变成下面的function over(id){
    var h = parseInt(id.height);
    if (h < 164){
    tr.height = h + 2;
    }
    }
    var SendYourId ="你的Id";//SendYourId是你的id 不是字符串
    setTimeout((function(GetYourId){return over(GetYourId)})(SendYourId),1000);
      

  7.   

    如果还是不行就
    下面的,这个一定行。(上面的你要试试啊,我就不试了)var SendYourId ="你的Id";//SendYourId是你的id 不是字符串
    setTimeout((function(GetYourId){
    return function over(id){
       var h = parseInt(id.height);
       if (h < 164){
          tr.height = h + 2;
       }
    };
    })(SendYourId),1000);
      

  8.   

    这个我测试的效果是立即执行下面这个就可以了<script>  
    function over(id){
    alert(id);
    }setTimeout(function(){over("aa")},1000);
    </script>