mjeczyk
mjeczyk

Reputation: 31

show/hide div depening on input value

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.

Upvotes: 1

Views: 825

Answers (1)

kander
kander

Reputation: 4306

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.

Upvotes: 2

Related Questions