JSFiddle - React, Tailwind, and code Playground

HTML

<h1>Test</h1>
<h1>Test Lagi</h1>
<h1>Test Lagi ah</h1>

CSS

span {background:yellow}

JavaScript

function wrapFirstWord($el, word){
    $el.each(function(){
        var txt = $(this).text();
        var wordArray = txt.split(' ');
        if(wordArray[0] === word && wordArray.length > 1){
            var newHTML = '<span>' + word + '</span>';
            for(var i = 1; i < wordArray.length; i++){
                newHTML += ' ' + wordArray[i];
            }
            $(this).html(newHTML);
        }
    });
}

$(function(){
    wrapFirstWord($('h1'),'Test');
});