javascript+css實現單擊顏色褪去效果_javascript技巧

來源:互聯網
上載者:User
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> <style type="text/css"> p{ font-size: 12px; font-family: Arial; } input{ cursor: pointer; } </style> <script type="text/javascript"> function flash(ts){ var p_obj=document.getElementsByTagName("p")[0]; if(ts<100){ p_obj.style.background = "rgb(100%,100%,"+ts+"%)"; ts += 4; setTimeout(function(){flash(ts);},100); } } </script> </head> <body> <p>"黃褪"效果</p> <input type="button" value="Click!" onclick="flash(60)" /> </body> </html>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]
相關文章

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.