0

I want to select a word by double clicking on it and then highlight all the findings of that word in that particular portion of page i.e. in that particular div only using jquery. Thanx in advance

s123
  • 1
  • 2
  • I know there's a question like that here on SO with a great answer. – keyser Oct 01 '12 at 06:51
  • This is a good start http://stackoverflow.com/questions/12505602/slow-highlighting-in-firefox/12505656#12505656 – elclanrs Oct 01 '12 at 06:51
  • I am able to select a word by simply double clicking it, then find and highlight all the occurrences of that word in the whole page but I don't know how to highlight in a particular div only. Actually the text in the div is loaded at runtime. – s123 Oct 03 '12 at 06:00
  • Hey @Keyser can u give me the link of that question. – s123 Oct 03 '12 at 06:02
  • No, I can't find it. But I've read it :p So it **does** exist – keyser Oct 03 '12 at 07:38

1 Answers1

1

Simple thougts...

Give your div an id, so you can search in that id with jquery.

Get all the text of that div, and split it by an space { }.

now loop throug the text. if it compares to the selected one, make span around it, and set an background on that span...

Mathlight
  • 6,436
  • 17
  • 62
  • 107