Realtime Search

by mattography

HTML

<body>
    <input type="text" id="highlighter"></input>
    <em>COMPRESSED AIR PIPING SYSTEMS C799 BIBLIOGRAPHY ASPE Data Book Vol 2 19811982 Casillo Antonio Sizing Air Compressors Plant Engineering December 1984 Compressed Airan> and Gas Handbook Fourth Edition Compressed Air and Gas Institute Compressed Air Fundamentals Ingersoll-Rand Company Compressed Air Systems Varigas Research Inc 1984 Cunningham ER Air Compressors Plant Engineering May 1980 Ferrara AJ Design for Compressed Air Air Conditioning Heating and Ventilating 1964 Frankel M Facility Piping Systems Handbook McGraw-Hill New York 1966 Foss R Scott Fundamentals of Compressed Air Systems Plant Engineering May 1981 Galus T How Much Air-Drying Equipment is Necessary Hydraulics and Pneumatics Magazine April 1989 Guidelines for Construction and Equipment of Hospital and Medical Facilities AIA 1992</em>
</body>

JavaScript

$(document).ready(function(){
  $("#highlighter").bind('keyup', function(e){
    var text = $.trim($(this).val());
    if(text !== '' && text !== ' '){
      var pattern = new RegExp(text, "gi");
    }
    $('p, div, span, em').each(function(i){
        var str = this;
        var orgText = $(str).text();
            orgText = orgText.replace(pattern, function($1){
            return "<span style='background-color: yellow;'>" + $1 + "</span>";
        });
     $(str).html(orgText); 
    });   
  });
});