Why are these checkboxes not working properly?

Watch the violin

  • Click jQuery. "last stable" is checked.
  • Click again. "last stable" is not checked.
  • Click "last stable". "jQuery" is being tested.
  • Click again. "jQuery" is not checked
  • Click jQuery
  • Click "last stable"; they go out of sync

Why? I am trying to get them to stay in sync (i.e., if any of the sub-checkboxes are checked, the parent checkbox should be checked, and vice versa). Clicking on an unverified parent must verify the top child; otherwise, if it has already been verified, it should disable all children). It seems that checktop.checked does not accurately reflect the user interface.

Edit: Tested in FF7, Chrome 16, IE9.

updated script - This is a warning “I checked” (if you follow the instructions) when I expect it to say: I’m not checked “because you just unchecked the box and the change event should trigger an afterword.

+4
source share
2 answers

Replace all occurrences of "attr ()" with "prop ()" http://jsfiddle.net/Cqt5Q/8/

+7
source

I only notice that this happens when:

  • click jQuery
  • unclick last stable (at the moment)
  • unclick jQuery

If you use the prop function instead of attr , it should work accordingly. I notice that Dr. Mollet and I came to the same conclusion almost at the same time :)

+2
source

All Articles