<div class="container">
  <h2><a href="https://mir3z.github.io/texthighlighter/" target="_blank">TextHighlighter</a> demo</h2>
  <div class="panel panel-default">
    <div class="panel-heading">
      Select some text to see the plugin in action
    </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>Last selected text:</div>
  <div class="log"></div>
</div>
/**
 * The following is not related to the plugin
 */
body {
  background: #fbfcfc;
}

.container {
  max-width: 700px;
}

.log:not(:empty) {
  padding: 5px;
  background: #16a085;
  color: #fff;
}
$(function() {
  var $context = $(".context");
  var $log = $(".log");
  $context.textHighlighter({
    "onAfterHighlight": function(arr, element) {
      $log.html(element[0].innerHTML);
    }
  });
});

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
  3. https://cdn.rawgit.com/mir3z/texthighlighter/master/src/TextHighlighter.js
  4. https://cdn.rawgit.com/mir3z/texthighlighter/master/src/jquery.textHighlighter.js