Linked Questions
108 questions linked to/from How can I pass a parameter to a setTimeout() callback?
8
votes
8
answers
44k
views
How to pass parameters to setTimeout function [duplicate]
I am relatively novice to javascript. I have written a simple counter program that starts count down from 10 till it reaches 1.
<script type="text/javascript">
function countDown(secs) {
...
7
votes
3
answers
2k
views
Pass $(this) into setTimeout function in mouseover [duplicate]
I am trying to show a div of information on a bar graph if the user hovers over the bar for a second. The answers on this site have gotten me to this point
var timer;
$(".session_hover").on({
'...
1
vote
3
answers
1k
views
Why does setTimeout require anonymous function to work? [duplicate]
I was reading an answer on StackOverflow here that explained how to use setTimeout to create a sort of recurring loop on a webpage. However, I am wondering why setTimeout requires an anonymous ...
3
votes
2
answers
2k
views
setInterval doesn't seem to like () in the function it invokes. Why? [duplicate]
When I execute the following, incidentController gets called after 10 seconds and continues to execute with no problems every 10 seconds:
// This works fine in nodejs v0.11.13
setInterval(...
2
votes
1
answer
2k
views
function in setTimeout doesn't work [duplicate]
There are two functions hello1() and hello2().
function hello1(){
console.log('hello1');
}
function hello2(){
console.log('hello2');
}
setTimeout(hello1, 3000);
setTimeout(hello2(), 3000);
...
0
votes
2
answers
2k
views
how to call function inside a function with setTimeout [duplicate]
I am trying to call a function with setTimeout() inside another function and I keep getting this error:
hi is not defined
This is the code.
hello("hi");
function hello(a)
{
hi(a);
function ...
1
vote
2
answers
2k
views
How to pass this function into settimeout with parameters? [duplicate]
var test = function(a, b) { return a + b; };
setTimeout(test(2, 3), 3000);
it shows some type error
-1
votes
1
answer
2k
views
How pass variable in function setInterval with javascript? [duplicate]
I want to pass a variable in a function inside setInterval, i'm tried with this code but doesn't work.
Anyway function orologio(arg) append in a div a variable returned by other function orario_sisma ...
2
votes
3
answers
274
views
setTimeout() doesn't allow me to pass text values [duplicate]
Possible Duplicate:
How can I pass a parameter to a setTimeout() callback?
Is there ever a good reason to pass a string to setTimeout?
I want to call a function loadPHPQuote(code) after 1 second....
-2
votes
2
answers
793
views
If condition not working inside a callback function [duplicate]
if i write like so, things work
var p1Button = document.getElementById("p1Button");
var p1Score = 0;
var p1Span = document.getElementById("p1ScoreSpan");
var p2Button = document.getElementById("...
2
votes
3
answers
406
views
Using setTimeout inside function [duplicate]
I'm trying to use setTimeout inside a function in which I provide the callback and the delay. I can't seem to get this to work.
Here's my code:
const timeout = function(cb, ms, msg) {
setTimeout(cb(...
0
votes
2
answers
205
views
Why is setTimeout acting synchronously? [duplicate]
Example of setTimeout being executed after a synchronous code is below it
console.log('hello');
setTimeout(() => console.log('timeout'), 0);
console.log('end');
Console Output:
hello
end
...
1
vote
2
answers
360
views
How to pass multiple element to a setTimeOut function [duplicate]
I have the following code:
for (z=0;z<7;z++) {
x = Math.floor((Math.random() * 7));
//I am pulling some class names from an array here
var element = document.querySelector("." + map[x]);
//...
0
votes
3
answers
204
views
How to pass function to the setInterval? [duplicate]
I have this function:
function executeCommand(callback) {
let params = {screen_name: '...'};
client.get('/statuses/user_timeline', params, function(error, tweets) {
if (JSON.parse(...
-1
votes
2
answers
656
views
I had an error when I passing a string argument to a function? [duplicate]
I'm sorry. I don't know how to describe this problem carefully.so I hope put my code first.
var test = 'less';
function test_I(tite) {
console.log(tite);
}
var repeat = "test_I('"+test+"')";
...