I am trying to get different div elements in a document to change, more specifically at this stage to apply a border around the elements on a timer,
here is what I have so far,
<style type="text/css">
.selected { border-style:solid; border-width:5px; }
</style>
<script type="text/javascript">
function sleep(delay){
var start = new Date().getTime();
while(new Date().getTime() < start + delay);
}
function start() {
var myBody = document.getElementsByTagName("body");
var children = document.body.children;
var temp;
//make sure current element has children
if(children.length > 0)
{
var i = 0;
if(children[0].children.length <=0)
{
i = 1;
}
for(i; i<children.length; i++)
{
if(children[i].tagName == 'DIV')
{
//alert("changing now");
temp = children[i].className;
children[i].className = 'selected';
//alert(children[i] + " class name is now " + children[i].className);
sleep(3000);
children[i].className = temp;
}
}
}else{
alert ("Script error, unable to read content " + children);
}
}
</script>
the for debugging, the code is set to run when I click anywhere on the body,
when I step through the code in chromes javascript debugger, it works. If I uncomment the alerts, it works, but if I just let it run, it does not.
Any idea's what is going on?

New Topic/Question
Reply



MultiQuote


|