小编Bro*_*Sol的帖子

随机多彩字母

我有这个代码:

<div  id="list" rows="10"></div>
<script>
 $(function() {
   setTime();
   function setTime() {
       $.ajax({
            url : "../abc.php",
            dataType: "text",
            success : function (result) {
                $("#list").html(result);
            }           
        });
      var date = new Date().getTime();
      setTimeout(setTime, 3000);
      $('#list').html(result);
      //Here  should call a function to color all the words of the div
   }


    });
</script>

    });
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用该setTime ()功能每3秒为所有字母着色.

注意:我正在尝试为一个单词的每个字母着色,换句话说,每个字母都会有一个颜色

喜欢:

https://i.imgur.com/Tw2Q58U.png

我尝试使用此代码,但它会更改整个div的颜色(div只保留一种颜色):

var randomColor = Math.floor(Math.random()*16777215).toString(16);
document.getElementById('list').style.color = '#' + randomColor

Run Code Online (Sandbox Code Playgroud)

html javascript

6
推荐指数
1
解决办法
173
查看次数

标签 统计

html ×1

javascript ×1