Hi guys,
The code works perfect on fiddle (check link below) but doesnt work properly when i upload the same code online. What have I done wrong?
Hi guys,
The code works perfect on fiddle (check link below) but doesnt work properly when i upload the same code online. What have I done wrong?
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.
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>
Thanks a lot! This helped
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.