Could someone please help me with this. First let me put up the code.
HTML:
<div id="FirstChild" style=" background-color: red; width: 100px; height: 50px; margin: 5px;"></div>
JavaScript:
window.onload = someThing;
function someThing(){
window.onclick = WidthChange;
}
function WidthChange(){
var presentWidth = parseInt(document.getElementById("FirstChild").style.width);
document.getElementById("FirstChild").style.width = presentWidth + 1 +"px";
setTimeout(WidthChange(), 3000);
}
Now, I want to increase the width of the div by 1 px after every 3 second when the user clicks on the window. I want this to happen forever. But it doesnt work. When I click on the window, the width immediately increases. I know how to do it with jQuery animate() and I don't want to use that. Only Javascript please!