JSFiddle - React, Tailwind, and code Playground

by Cath_kb

HTML

<span data-content=' any other text you may want'>foo</span>

CSS

span:after {
    content: attr(data-content);
}

JavaScript

var data = $('span').attr('data-content');
$('span').on({
    mouseenter: function() {
        $(this).attr('data-content', ' bar');
    },
    mouseleave: function() {
        $(this).attr('data-content', data);
    }
});