Adding Class to Words of a Sentence with jQuery

	// Adding class to the 1st word of a sentence

	$(".rsceb-date").html(function(){
  		var text= $(this).text().trim().split(" ");
  		var first = text.shift();
  		return (text.length > 0 ? "<span class='special'>"+ first + "</span> " : first) + text.join(" ");
	});
    // Adding class to the 1st, 2nd, and Last word of a sentence

        $('.post-meta .published').html(function(_, existing) {
          var words = existing.trim().split(' ');
          words[0] = '<span class="firstword">' + words[0] + '</span>';
          words[1] = '<span class="secondword">' + words[1] + '</span>';
          words[words.length - 1] = '<span class="lastword">' + words[words.length - 1] + '</span>';
          return words.join(' ');
        });
Scroll to Top