settimeout 传递带有参数的函数

方法一:传递带有参数的function给settimeout,写个函数,该函数返回一个不带参数的函数
<script language="javascript">
    function show(name)
    {alert("Hello World:" + name);}

    function _show(name)
    {
        return function()
        {
            show(name);
        }
    }
    setTimeout(_show(name),1000);
</script>

 方法二:function(){ method(param);} 

function timeClick(obj)  
       {  
        //   var obj=document.getElementById('');  
           obj.style.backgroundColor=&quot;gray&quot;;  
           obj.onclick=function(){ return false;};  
           setTimeout(function(){resetbgColor(obj);},3000);  
       }  
         
       function resetbgColor(obj)  
       {  
         //  var obj=document.getElementById('');  
           obj.style.backgroundColor=&quot;&quot;;  
        //   $('#'+'').click(timeClick);  
      //  debugger;  
           obj.onclick=function(){  
               timeClick(this);  
           };  
       }  

 

posted @ 2013-12-24 19:13  ``炯``  阅读(691)  评论(0编辑  收藏  举报