JS按钮闪烁功能的实现代码

html

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

js

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

总结

以上所述是小编给大家介绍的JS按钮闪烁功能的实现代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!