<div class="container">
  <h2><a href="http://hawkee.com/snippet/9854/" target="_blank">highlight_words</a> demo</h2>
  <div class="panel panel-default">
    <div class="panel-heading">
      <form>
        <div class="form-group">
          <label for="keyword">Search term:</label>
          <input type="text" class="form-control input-sm" value="Lorem" name="keyword" id="keyword">
        </div>
        There is no way to remove highlights with this plugin, so you can not update the search term dynamically.
      </form>
    </div>
    <div class="panel-body context">
      <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
        takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores
        et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
    </div>
    <div class="panel-footer">This example is part of the article <a href="http://www.sitepoint.com/10-jquery-text-highlighter-plugins/" target="_blank">10 jQuery Text Highlighter Plugins</a> on <a href="http://sitepoint.com/" target="_blank">SitePoint</a> by <a href="https://github.com/julmot" target="_blank">Julian Motz</a>.</div>
  </div>
</div>
span.highlight{
  background: #f1c40f;
}

/**
 * The following is not related to the plugin
 */
body{
  background: #fbfcfc;
}
.container{
  max-width: 700px;
}
$(function() {
  var $context = $(".context p");
  var $form = $("form");
  var $input = $form.find("input[name='keyword']");


    // Determine search term
    var searchTerm = $input.val();

    // As there is no way to remove
    // previous highlights, we simply
    // highlight the current search term
    highlight_words(searchTerm, $context);

});
/**
 * Copyright (c) 2013, Hawkee
 * License unclear
 */
function highlight_words(keywords, element) {
    if(keywords) {
        var textNodes;
        keywords = keywords.replace(/\W/g, '');
        var str = keywords.split(" ");
        $(str).each(function() {
            var term = this;
            var textNodes = $(element).contents().filter(function() { return this.nodeType === 3 });
            textNodes.each(function() {
              var content = $(this).text();
              var regex = new RegExp(term, "gi");
              content = content.replace(regex, '<span class="highlight">' + term + '</span>');
              $(this).replaceWith(content);
            });
        });
    }
}

External CSS

  1. https://maxcdn.bootstrapcdn.com/bootswatch/3.3.6/sandstone/bootstrap.min.css

External JavaScript

  1. https://code.jquery.com/jquery-2.2.3.js
  2. https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js