Jump to content

Trying to get one line of text to fade into black background


AARRGGHHH

Recommended Posts

When I step through this, it never changes to black.  It just stays red. 

  <body onload = "hideQuote0();">

		<script>
          
			function hideQuote0()
			{
				document.getElementById("span0").color = "rgb(255,0,0)"; 
				setTimeout(hideQuote1(), 3000); 	
			}
			function hideQuote1()
			{
				document.getElementById("span0").color = "rgb(128,0,0)"; 
				setTimeout(hideQuote2(), 3000); 	
			}
			function hideQuote2()
			{
				 document.getElementById("span0").color = "rgb(0,0,0)"; 
			}
				 
		</script>

		<div id="div0" style.display = "block";> 
			<span id="span0" color: rgb(0,0,0);> QUOTE GOES HERE </span><br><br> 
		</div> 	
    
    	...
    
  </body>

   Thank you very much

 

Edited by AARRGGHHH
Link to comment
Share on other sites

Accomplished what I wanted with CSS Animation: 

<style>
	p {text-align: center;} 
		
	#span0 
	{
		animation: animate 8s;
		animation-iteration-count: 1;
	}

	@keyframes animate
    	{
    		from {color: rgb(255,128,64);}
        	to {color: black;}
    	}
		
</style> 

	<div id="div0" style.display = "block";> 
		<span id="span0">QUOTE GOES HERE</span><br><br> 
	</div> 	

But I am curious as to why I was unable to get it to work using the JavaScript setTimeout() function.  If anyone knows, please share the knowledge! 

Thank you  

Edited by AARRGGHHH
Link to comment
Share on other sites

If you want to use inline CSS you MUST use STYLE to do so.

 


          
			function hideQuote0()
			{
				document.getElementById("span0").style.color = "rgb(255,0,0)"; 
				setTimeout(hideQuote1, 3000); 	
			}
			function hideQuote1()
			{
				document.getElementById("span0").style.color = "rgb(0,255,0)"; 
				setTimeout(hideQuote2, 3000); 	
			}
			function hideQuote2()
			{
				 document.getElementById("span0").style.color = "rgb(0,0,0)"; 
			}


<div id="div0" style.display = "block";> 
			<span id="span0" style="font-weight: 900; color: rgb(0,0,0);"> QUOTE GOES HERE </span><br><br> 
		</div> 	

 

Edited by dsonesuk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...