Home  >  Article  >  Web Front-end  >  How is the JS button flashing function implemented?

How is the JS button flashing function implemented?

零下一度
零下一度Original
2017-07-24 20:03:432239browse

The implementation code of the js button flashing function is divided into two parts: html and js code. Please refer to this article for the specific implementation code

html


# #

<body onload="blinklink()" onunload="stoptimer()">
  <a href="javascript:;" rel="external nofollow" class="iforeginbtn" id="flashit">马上注册领取</a>
</p>

js


var flashit=document.getElementById(&#39;flashit&#39;);
function blinklink(){
if(flashit.style.backgroundColor==&#39;rgb(232, 83, 63)&#39;){ //注意:这里拿到的是rgb格式的
  flashit.style.backgroundColor=&#39;#485fbd&#39;;
 }else{
   flashit.style.backgroundColor=&#39;rgb(232, 83, 63)&#39;;
 }
  timer=setTimeout("blinklink()",300);
}
function stoptimer(){
  clearTimeout(timer);
}

The above is the detailed content of How is the JS button flashing function implemented?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn