views:

54

answers:

1

I want to show div#cool when user will type "cool" in input field or div#good when user will type "good" and so on. Everything should work in real-time.

+2  A: 

Edit: Created a Github Gist for it: http://gist.github.com/488611 - thanks for the comments, keyPress should indeed have been keypress. I've never had reliability issues with it myself?

In this case, we're assuming that all divs are in a parent element #divs. so they're hidden when the user changes the input.

Note: untested, so it may not work turn-key, but the gist is right.

kander
I noticed that `keyPress` does not work reliable in all browsers.
Felix Kling
jAndy
@jAndy: Check out my answer [here](http://stackoverflow.com/questions/2977428/jquery-mirror-one-text-input-to-another/2977449#2977449). For some reason `keypress` did not work properly (the first key press was not detected). But I only tested it in Firefox and now in `3.6.7` it seems to work. Or the reason for this problem was something else.
Felix Kling