jQuery has a hard time dealing with text after something you’ve selected. But now it’s easy thanks to the jQuery afterText Plugin. Just change the text after something with the afterText() function:
$('.red').afterText('This is red!'); $('.blue').afterText('This is blue!');
The difference to after(text) is that afterText(text) replaces any existing text (including empty text). It’s so simple! You can grab it on Github.
Related: How to remove text from after an element with jQuery