JSFiddle - React, Tailwind, and code Playground
HTML
<p id='detailBoxParagraph'>Lorem Ipsum is simply <b>dummy text</b> of the printing and typesetting industry. Lorem Ipsum has been the industry's standard <b>dummy text</b> ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the <b>1960s</b> with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum</p>
JavaScript
function alertSelection() {
$("b", $('#detailBoxParagraph')).wrap('<i/>'); // make the highlighted section inside a tag.
$("b", $('#detailBoxParagraph')).before('<u>Content inserted before </u> '); // insert an html before highlighted selections.
$("b", $('#detailBoxParagraph')).after(' <u>Content inserted after </u>'); // insert an html after highlighted selections.
}
$(function () {
alertSelection();
})