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="gray"; obj.onclick=function(){ return false;}; setTimeout(function(){resetbgColor(obj);},3000); } function resetbgColor(obj) { // var obj=document.getElementById(''); obj.style.backgroundColor=""; // $('#'+'').click(timeClick); // debugger; obj.onclick=function(){ timeClick(this); }; }

浙公网安备 33010602011771号