javascript - How to pass arguments to a function in setTimeout -


i have following code:

function fn($){   return function(){     innerfn = function(){       settimeout(show, 1000);     };      show = function(){       $.alert("test");     }   } } 

but, after 1 second, when function show run, says $ undefined. how resolve issue?

how pass arguments function in settimeout

settimeout has built in mechanism adding params

var timeoutid = window.settimeout(func, delay, [param1, param2, ...]);

use it.

if you're going use this - should careful. that's question.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -