It’s been a while since I worked with JavaScript – after my cert I began learning Perl and have worked with it ever since. I am just trying to get my hand back in and for a start with JS, I have written this what I would have said, was a simple, little script to change a border of a div quite simply. I cannot work out however, just where I’m going wrong. Appreciated of any advice/suggestion or ideas. TY in advance. Here’s my script..
<script type="text/javascript">
var i =0;
var e = document.getElementById("text");
e.style.border = "solid black 5px";
e.style.padding = "5px";
var colors = ["red", "yellow", "blue", "green"];
function changeBorder()
{
e.border = colors[i];
i++;
var timer = setTimeout("changeBorder()", 1000);
}
window.onload=function()
{
changeBorder();
}
</script>
<div id="text">
<h1>Hello world</h1>I am Mike!.
</div>
try this: http://jsfiddle.net/maniator/CEsJR/
the
evariable can only be created on page load