Change Text Color with Javascript
Below is the simple and sweet code of changing text color after fraction of second automatically. Copy n Paste and run...
<html>
<head>
<title>Text Color Change</title>
<script type="text/javascript" language="javascript">
elmColor = 0;
function changeColor(elmColor)
{
switch(elmColor)
{
case 0:
document.getElementById('colorChange').style.color = '#000000';
elmColor++;
break;
case 1:
document.getElementById('colorChange').style.color = '#ff0000';
elmColor++;
break;
case 2:
document.getElementById('colorChange').style.color = '#00ff00';
elmColor++;
break;
case 3:
document.getElementById('colorChange').style.color = '#0000ff';
elmColor++;
break;
case 4:
document.getElementById('colorChange').style.color = '#0688ad';
elmColor++;
break;
case 5:
document.getElementById('colorChange').style.color = '#2f6202';
elmColor++;
break;
case 6:
document.getElementById('colorChange').style.color = '#c26a14';
elmColor++;
break;
case 7:
document.getElementById('colorChange').style.color = '#cf013b';
elmColor = 0;
break;
default:
break;
}
setTimeout(function(){changeColor(elmColor);}, 700);
}
window.onload = function(){changeColor(elmColor);};
</script>
</head>
<body>
<div style="width:70%; margin:0 auto; font-family:Verdana; font-size:50px; font-weight:bold;" id="colorChange" >
Hello.... <br><br>
I am changing my text color with the help of Javascript..... <br><br>
Thankyou Javascript.......... :)
</div>
</body>
</html>
Demo Here:-
http://www.navvtech.com/demo/javascript/blink/changeColor.html
I remember this day..,.,i got help from You.,.Thank u sir
ReplyDeleteu r welcome
ReplyDeletevery usefull for me..... and cool.
ReplyDeletetanks sir...
thanks for help ....
ReplyDeletethis script really good ,, i did not repeat another time in one page....' i want change my paragraph color another time... how is it possible please let me know ...
ReplyDeletehere is your solution. Please follow the link
Deletehttp://anishrana.blogspot.in/2015/03/change-text-color-with-javascript-at.html
tanx
ReplyDelete