Geeks With Blogs
kazim mehdi
It uses an array of keywords to search and when found mark them like google highlight search keywords e.g jquery  this code searches in complete body tag if you like to do search at a specific place then replace "body" with any of the jquery selector that suits your situations.
<script type="text/javascript">
function HighlightKeywords(keywords)
var el = $("body");
    var pattern = new RegExp("("+this+")", ["gi"]);
    var rs = "<span style='background-color:#FFFF00;font-weight: bold;background-color:#FFFF00;'>$1</span>";
    el.html(el.html().replace(pattern, rs));
<script type="text/javascript">
HighlightKeywords(["got", "the"]);
Posted on Wednesday, April 29, 2009 1:03 AM jquery | Back to top

Comments on this post: Keyword Highlight on a web page using jquery

# re: Keyword Highlight on a web page using jquery
Requesting Gravatar...
please explain with html complete code
Left by ramkumar on Oct 27, 2009 12:52 AM

Your comment:
 (will show your gravatar)

Copyright © kazim sardar mehdi | Powered by: