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

How is the JS button flashing function implemented?

零下一度
Release: 2017-07-24 20:03:43
Original
2336 people have browsed it

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>
Copy after login

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);
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template