JSFiddle - React, Tailwind, and code Playground

HTML

<div id="div">dfggfgmmmn</div>

JavaScript

$("#div").html(function(){
    return $(this).html().substring(0,4)
});