JSFiddle - React, Tailwind, and code Playground

by Norlihazmey Ghazali

HTML

<h1>Hello you there</h1>

<h1>Hi u there</h1>

<h1>Can we go there</h1>

CSS

.myColor{
  color : red
}

JavaScript

var text = $('h1').text().split(' ');
var lstWord = text.pop();
$("h1:eq(0)").html(function(i, old) {
   return old.replace(lstWord, '<span class="myColor">'+lstWord+'</span>');
});