JSFiddle - React, Tailwind, and code Playground

HTML

<div class="pagination">
  <a href="#">1</a>
  <a href="#">2</a>
  3
  <a href="#">4</a>
</div>

CSS

span{
    color:red;
}

JavaScript

$(function() {

    var test = $('.pagination').contents()
    .filter(function() {
        return this.nodeType === 3 && $.trim(this.nodeValue) !== '';
    }).wrap('<span/>');
    
});