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.
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.
精彩评论