Forum Moderators: open
First I created the function called grow- (Note: The following are pasted in the appropriate places in the full document.)
function grow(name)
{
var(name).style.width='150px'
}
Then, here is my link lower down on the page.
<div id="Home" style="background-color:#FFCC00; width:100px;" align="right" onmouseover="grow('Home')" onmouseout="this.style.width='100px'"> Homepage
</div>
What am I doing wrong?
interval = 0;
width=100;
function grow(name)
{
if(interval<11){
var expand = document.getElementById(name);
interval = interval + 1;
width = width + 5;
expand.style.width = width +"px";
growTime=setTimeout("grow(name)",100);
}else{
interval = 0;
width=100;
}
}
Any ideas? Thanks.
growTime = setTimeout(function () {
grow(name);
}, 100);
It's best not to pass quoted strings to the setTimeout function. Instead, pass a function reference. In the example above, I'm passing an anonymous function which calls the grow function with the name argument.
[edited by: Fotiman at 6:44 pm (utc) on July 6, 2009]