JSFiddle - React, Tailwind, and code Playground

HTML

<div>
    <h2>This is the first</h2>
    <h2>This is the second</h2>
    <h2>This is the third</h2>
</div>

CSS

h2 span{ color:red; }

JavaScript

$.fn.wrapStart = function(numWords){
	return this.each(function(){
		$this = $(this);
		var node = $this.contents().filter(function(){
			return this.nodeType == 3
		}).first(),
		text = node.text(),
		first = text.split(" ", numWords).join(" ");
		if (!node.length) return;
		node[0].nodeValue = text.slice(first.length);
		node.before('<span>' + first + '</span>');
	});
};

$("h2").wrapStart(1);