This article describes the JavaScript automatically change the text size and color effects of small examples, the need for friends can refer to the
copy code code as follows:
<body bgcolor= "#000000" >
<div id= "text" style= "font-size:20px;" > Hello, this is a JavaScript code to change the size and color of text </div>
<script type= "Text/javascript" >
var size = 20;
var falg = 1;
function Colortext ()
{
//Get the size of the text
document.getElementById ("text"). Style.color = GetColor ();
document.getElementById ("text"). Style.fontsize = GetSize ();
}
//Set text color
function GetColor ()
{
var mycolor = "#";
var color = "123456789abcdef";
var colorcode = Color.split ("");
for (var i=0;i<6;i++)
{
Mycolor+=colorcode[math.floor (15*math.random ())];
}
return mycolor;
}
//Return font size
function GetSize ()
{
if (falg = 1)
{
size = size+1;
if (size = = 60)
falg = 0;
return size;
}
if (falg = 0)
{
size = size-1;
if (size = = 20)
falg = 1;
return size;
}
}
setinterval ("Colortext ()", 200);
</script>
</body>