tlob wrote:
works like a charm!
Excellent :)
but I dont get it... -blur is the opposite of focus, right?
Yep - focus is triggered when the user tabs or clicks into the input - blur is triggered when they tab or click out of it so it's no longer the active element.
-why do you chain it after the focus?
'tis the jQuery way! What we're basically doing is saying "with the input in #schnellsuche, add a focus handler, then add a blur handler".
-with [0].defaultValue you restore the first value that was stored in an array?
Not quite. If you imagine $(this) as an array of DOM objects within jQuery, then $(this)[0] is a way to access the first (or in this case, only) DOM object. jQuery doesn't have a built in way to retrieve the default value of an input, so we have to nip back into the DOM momentarily in order to retrieve it.
-does JS store every changed value of every element in an array?
The DOM contains a defaultValue attribute for every text input, textarea and select box. Not sure about checkboxes and radio buttons.
I invite other people to clear up any parts of my reply which aren't totally accurate (you can tell I have faith in my ability to explain things properly, I must say this in every post!)
Regards, Michael Price