Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 生成更改颜色的文本_Html_Text_Colors - Fatal编程技术网

Html 生成更改颜色的文本

Html 生成更改颜色的文本,html,text,colors,Html,Text,Colors,我想让文本自动改变颜色,有人能帮我吗? 比如说,改变颜色的文字 此消息 它将每隔一秒改变一次红色/黑色的字母。您可以使用jQuery <!DOCTYPE html> <html> <head> <script src="//code.jquery.com/jquery-1.9.1.min.js"></script> <script> $(document).ready(function(){ var y

我想让文本自动改变颜色,有人能帮我吗? 比如说,改变颜色的文字 此消息
它将每隔一秒改变一次红色/黑色的字母。

您可以使用jQuery

<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>

<script>
    $(document).ready(function(){
      var y;

    setInterval(function () {
      if (y == 0) {
          $('.text').css('color','#ff0000');
          y = 1;
      } else {
          if (y = 1) {
            $('.text').css('color','#999');
              y = 0;
          }

      }
    }, 1000); // change the time if you want

    });


</script>
</head>
<body>
<span class="text">Change color text</span>

</body>
</html>

$(文档).ready(函数(){
变量y;
setInterval(函数(){
如果(y==0){
$('.text').css('color','#ff0000');
y=1;
}否则{
如果(y=1){
$('.text').css('color','#999');
y=0;
}
}
},1000);//如果您愿意,可以更改时间
});
更改颜色文本

不确定这是否是您想要的,但此jquery将每秒自动更改颜色


我希望这能解决你的问题

我不确定我是否理解你的问题。你能举一些你已经尝试过的例子吗?
function randomcolor() {
    $('h1').each(function () {
        var hue = 'rgb(' + (Math.floor((256)*Math.random())) + ',' + (Math.floor((256)*Math.random())) + ',' + (Math.floor((256)*Math.random())) + ')';
        $(this).css("color", hue);
    });
}
randomcolor();

setInterval(function(){randomcolor();}, 1000);