How do I alternate letter colors on a webpage using javascript?

前端 未结 4 1053
星月不相逢
星月不相逢 2021-01-24 15:05

I\'m trying to alternate the colors of every letter in a specific div on my webpage using javascript.

I found this script on a forum that alternates the color of the wor

4条回答
  •  悲&欢浪女
    2021-01-24 15:27

    Replace this:

    var text = HTML.split(' '), output = '';
    for (var w=0; w ';
    }
    

    With this:

    for (var c=0; c ';
    }
    

    The output's going to be pretty verbose. If you want to skip spaces, you'll need to add a little logic for that.

提交回复
热议问题