<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://www.w3school.com.cn/jquery/jquery.js"></script> <style type="text/css"> .changecolor1{color:red;} .changecolor2{color:blue;} </style> </head> <body> <script type="text/javascript"> function ChangeColor(){ $("#color1").toggleClass("changecolor1"); $("#color2").toggleClass("changecolor2"); setTimeout("ChangeColor()",1000) } ChangeColor(); </script> <a href="#" style="color:green;"><p id="color1">color1</p></a> <p id="color2">color2</p> </body> </html>
应用事例:
<a href="http://www.685939.com/" target="_blank" style="color:#FFE7AD;"><span id="color1">抢红包</span></a> <style type="text/css"> .changecolor1{color:#3CBB61;} .changecolor2{color:#CE5ADC;} </style> <script type="text/javascript"> function ChangeColor(){ $("#color1").toggleClass("changecolor1"); $("#color2").toggleClass("changecolor2"); setTimeout("ChangeColor()",1000) } ChangeColor(); </script>