JSFiddle - React, Tailwind, and code Playground

by ThiefMaster

HTML

<h2 class='date-header'>2011-01-20</h2>

JavaScript

$('.date-header').html(function() {
    var self = this,
        txt = $(this).text();
    var classes = ['dhy', 'dhm', 'dhd'];
    $(this).empty();
    $.each($.map(txt.split(/-/), function(val) {
        return $('<span/>', {'class': classes.shift()}).text(val);
    }), function() {
        $(this).appendTo(self);
    });
});