The syntax for the setTimeout function in javascript code below is correct
setTimeout("document.getElementById('test').style.display='none'",3000);
I want to substitute the var testdiv to shorten the code
testdiv = document.getElementById('test');
But when I substitute the var testdiv into the setTimeout call, it does not work with the syntax that I have.
setTimeout("testdiv.style.display='none'",3000); //does not work with wrapping dblquotes.
setTimeout(testdiv.style.display='none',3000); //does not work either.
What is the correct syntax for writing this statement using the short cut?
TIA
Use a function instead of a string.