开发者

show/hide div depening on input value

开发者 https://www.devze.com 2023-01-09 04:47 出处:网络
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 f

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消