当前位置:主页 > 网页前端 > JavaScript代码 >

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

时间:2021-03-18 09:44:59 | 栏目:JavaScript代码 | 点击:

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);
}

总结

您可能感兴趣的文章:

相关文章