Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何为函数设置 settimeout,该函数将在 5 秒后启动。
function test(fnn) { setTimeout(fnn,5000); } test($('#id').addClass('qwerty'));
传递的参数fnn是一个函数:
fnn
test(function(){ $('#id').addClass('qwerty'); });
你可以使用它。
setTimeout(function() { your_function(); }, 5000);