Live example: http://jsfiddle.net/69naX/1/
I click “show”, next click “one”, “two” etc, unclick etc. This doesnt work good. Next I click hide. This is OK.
Next I click “show” again and click “one” etc – this doesnt work. Next click “hide”, next click “show” – “one” etc this works good.
Next click “hide”, click “show” – click “one” etc doesn’t work. This repeat all the time every two.
How can i fix it? .live doesn’t help.
You define handlers when you click Show. So when you click it a second time, the handlers are defined twice and what happens is equal to normally clicking twice – selecting and unselecting directly.
Clicking three times on Show will result in normally clicking three times which works (selecting – unselecting – selecting). Four times again won’t, etc.
You could just move the click handlers of one, two, etc outside so that they get defined once only: http://jsfiddle.net/pimvdb/69naX/2/.