简体   繁体   English

如何使用脚本以2色显示文本?

[英]How to display text in 2 color using script?

How to display text in 2 color using script ? 如何使用脚本以2色显示文本?

first show text color #ccc 1 sec and then show text color #000 1 sec and then show text color #ccc 1 sec (loop) 首先显示文字颜色#ccc 1秒,然后显示文字颜色#000 1秒,然后显示文字颜色#ccc 1秒(循环)

JSFiddle 的jsfiddle

you can achieve that with setInvterval 你可以用setInvterval实现这一点

function changeColor()
{
    if(document.getElementById('mySpan').style.color == "rgb(0, 0, 0)" || document.getElementById('mySpan').style.color == "#000000")
    document.getElementById('mySpan').style.color = "#ccc";
    else
    document.getElementById('mySpan').style.color = "#000";
}

setInterval("changeColor()",1000);

and html: 和HTML:

<span id='mySpan'>some text</span>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM