首页 > 代码库 > 像歌词跟着声音走的JS文字效果

像歌词跟着声音走的JS文字效果

  • 一个比较不错的文字显示特效,像MTV的歌词显示一样跟着演唱者慢慢逐个清淅显示,这段特效代码就实现了和这个功能差不多,而且JS代码非常少,兼容性好,点击运行看看效果吧!
<html><head><title>石家庄花卉</title></head><body><script language="JavaScript">var message="像歌词显示一样JS文字效果!"var neonbasecolor="gray"var neontextcolor="blue"var flashspeed=100var n=0if (document.all){document.write(<font size="3" color="+neonbasecolor+">)for (m=0;m<message.length;m++)document.write(<span id="neonlight">+message.charAt(m)+</span>)document.write(‘‘)var tempref=document.all.neonlight}elsedocument.write(message)function neon(){if (n==0){for (m=0;m<message.length;m++)tempref[m].style.color=neonbasecolor}tempref[n].style.color=neontextcolorif (n<tempref.length-1)n++else{n=0clearInterval(flashing)setTimeout("beginneon()",1500)return}}function beginneon(){if (document.all)flashing=setInterval("neon()",flashspeed)}beginneon()</script></body></html>