A small example of the effect of JavaScript automatically changing the size and color of text

Source: Internet
Author: User
Tags getcolor
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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.