title: How to search text from page with next and previous functionality in jquery
body: <p>I am implementing the Text search functionality on page .I found lot of links .But i need more functionality .</p>
  
  <p>Here is good example
  <a href="http://jsfiddle.net/z7fjW/137/" rel="nofollow">http://jsfiddle.net/z7fjW/137/</a></p>
  
  <pre><code>function searchAndHighlight(searchTerm, selector) {
      if(searchTerm) {
          //var wholeWordOnly = new RegExp("\\g"+searchTerm+"\\g","ig"); //matches whole word only
          //var anyCharacter = new RegExp("\\g["+searchTerm+"]\\g","ig"); //matches any word with any of search chars characters
          var selector = selector || "body";                             //use body as selector if none provided
          var searchTermRegEx = new RegExp(searchTerm,"ig");
          var matches = $(selector).text().match(searchTermRegEx);
          if(matches) {
              $('.highlighted').removeClass('highlighted');     //Remove old search highlights
                  $(selector).html($(selector).html()
                      .replace(searchTermRegEx, "&lt;span class='highlighted'&gt;"+searchTerm+"&lt;/span&gt;"));
              if($('.highlighted:first').length) {             //if match found, scroll to where the first one appears
                  $(window).scrollTop($('.highlighted:first').position().top);
              }
              return true;
          }
      }
      return false;
  }
  </code></pre>
  
  <p>But I need  it only search first word(present first) then using next it goes to next (go to next position).Then previous (go to previous position).as in note pad ?
  Is this possible in query? </p>