Edited 2013-12-11 to use focusout rather than blur event
Continuing my adventures in developing an online editor, I wanted to be able to do "live" searching: having the text scroll to the sought string as it is being typed. I can use my bililiteRange
utilities to find an arbitrary regular expression, but after much hair-pulling, realized that my texthighlight
plugin is just too flaky and hack-dependent to be used reliably. So I went a different route: instead of trying to highlight strings in a <textarea>
, I overlay a <pre>
element desinged to look similar enough to the <textarea>
and highlight the string in that with normal HTML. When the user is done typing his search string (signaled by a blur
event on the <input>
element being typed in), remove the <pre>
and select the desired string in the original <textarea>
. There's a jump but not as bad as with texthighlight
.
See a simple demo, a demo that uses the parameters, and a demo that searches three elements at once.
Continue reading ‘New jQuery plugin,livesearch
’ »