javascript
First written: Jun-2023
last changed Dec-2023
last changed Dec-2023
Type-Watching input elements using the custom typewatch function
A typewatch is something that will wait for typing to finish before calling on a desired function; this type-watch takes three parameters - the target "watched" element, the callback to be called once the typing has stopped, and the delay required for typing to stop before calling the callback.
To implement a type-watcher against input fields you need to run through a few steps
- declare typewatch function
js :: typewatch declaration
- on the input, have a
input
event that callstypewatch(e.target, function(elem) {doSomething(elem.value);}, 600);";
- info Tip: You probably want to have this functionality on an input of type search
<input type='search'>
in order to include the clear button (X) at the right side of the input.js :: Example filter field
link Click to view a demo
square
Comments
New Comment