I trying to write a generic function which takes the function and number of milliseconds as argument and it sets it to setTimeout function. I tried: like
$("#Delay").click(function() {
delayCallBack(someFunction(a, b), 100);
});
In delayCallBack function:
function delayCallBack(event, time) {
setTimeout(function() {
event();
}, time);
};
But this is not working and throwing me JavaScript error. Can someone please help me with the right way of doing this?
Replace
With
The first line executes
someFunction(a,b)instead of what the second line does, passing a reference to a function to execute.