JSFiddle - React, Tailwind, and code Playground

by Van Peer

HTML

<body>
  <label name="lblKeyword" id="lblKeyword" class="highlight">keyword</label>
  <div id="results" class="results">
    <p class="filename">keyword</p>
    <p class="content">keyword</p>
    <p class="system">
      <i>keyword</i>
    </p>
    <p class="logfilepath">keyword</p>
    <hr/>
  </div>
</body>

CSS

.highlight {
  background-color: yellow;
}

JavaScript

$(document).ready(function() {
  var keyWord = $("#lblKeyword").text();
  var replaceD = "<span class='highlight'>" + keyWord + "</span>";
  $(".system, .filename, .content").each(function() {
    var text = $(this).text();
    text = text.replace(keyWord, replaceD);
    $(this).html(text);
  });
});