3
Contributors
3
Replies
17
Views
4 Years
Discussion Span
Last Post by SaroGFX
0

Both look OK to me. The 'online' seems a bit quicker. Try clearing the cache?

//EDIT

Hold on, no the 'online' halts after a little while and then starts again.

Ah, you seem to be running flicker() twice. Once in the head and once inline in the body-onload.

Edited by diafol

0

Yes, calling the function in both the head and body is causing that problem.

Here is your sample code consolidated in a working html file.

<!DOCTYPE html>
<head>
 <title>Flickering Logo</title>
 <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> 
 <style>
  div { width:50px; height:50px; border:1px solid gray; }
  div#box2 { background-color:red; }
  div { background-color:black; }
  div.on { background-color:white !important; }
</style>
</head>

<body>
 <div id="box"></div>
 <div id="box2" style="display:none"></div>
 <script>
  var interval = 300; 
  flicker(); 
    function flicker()
    {
        $("#box").toggleClass('on');
        setTimeout(flicker, interval)
    }
 </script>
</body>
</html>

Edited by JorgeM

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.