JSFiddle - React, Tailwind, and code Playground

HTML

<td><input type="text" class="ttt" value="          test"></td>

CSS

.changeMe{
    color:red;
}

JavaScript

//array of all the spans in the html document
var spansArray = $('span');
//iterate the array
spansArray.each(function() {
    var $this = $(this);
    console.log($this.text().length);
    $this.html($.trim($this.text()));
    console.log($this.text().length);
});