JSFiddle - React, Tailwind, and code Playground

by Amit Vishwakarma

HTML

<script src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css">
<p>I want to put a ding in the universe.</p>

CSS

.green {
    color:green;
}
.blue {
    color: blue;
}
.orange {
    color: orange;
}
.yellow {
    color: yellow;
}
.red {
    color: red;
}

JavaScript

var $p = $('p');

var array = $p.text().split('');

var colors = ['green','blue','orange','yellow','red'];

$.each(array, function( i ) {
    array[i] = '<span class="' + colors[ i % 5 ] + '">' + array[i] + '</span>';
});


$p.html(array.join(''));