how can i integrate the codes to make it loop infinte sir/ma'am? i'am a total newbiew, thanks in advance. :D

<script langauage="javascript">
col=255;
function fade ()
{ document.getElementById("fade").style.color="rgb("+ col + "," + col + "," + col + ")"; col-=5; if(col>0)
setTimeout('fade()',25);}
</script>

Recommended Answers

All 3 Replies

Can you elaborate on what exactly you are trying to do?

Are you trying to fade the color of an element?

i'm trying to fade some text and i want it loop infinite sir.

Use a recursive function. I dont understand how you are going to have an infinite loop on fading a color, but in any event, if you need help with the loop part, here is a sample that you can start with. Place your code within the are below labeled "Your code Here". The function will "loop" every 3 seconds. Change the timeout period to your needs.

<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
</head>

<body>
<script>
   function loop() {        
     // Your code Here  
     setTimeout("loop()", 3000); // 3000 milliseconds = 3 seconds    
   }    

loop();
</script>

</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.