JSFiddle - React, Tailwind, and code Playground JavaScript var string = "<br/>Hi"; alert($('<span>'+string+'</span>').text().substr(0, 7));