Method The article provides two of tested JS change font color code Oh, and so a set a specified ID to change the ID inside the font color method, the second is to traverse the entire document OH.
<html> <body> <script type= "text/web Effects" > function Chcolor () { document.getElementById ("T"). style.color= "Red"; } </script> <div id= "T" > How do I change the font color </div> <a href= "Javascript:chcolor ();" > Set me up for red </a> </body> </html>/Method Two
<head> <title> Variable Color fonts </title> <script language= "JavaScript" > function Bcolor () { var A=document.all.color1; if (a.style.color!= "red") A.style.color= "Red"; } </script> </head> <body> <form name= "Yuan" > <span id= "Color1" > Lin Haolin </span> <input type= "button" value= "click onclick=" Bcolor (); " >
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.