Wednesday 14 April 2010

Using jQuery to ensure only one checkbox is checked at a time

have a slightly dodgy UI.
A bunch of checkboxes that only one can be checked. It should be a radio button, but the problem with radio buttons are that it has to have a value - so that means adding a "null" button which is kind of crappy.

How to make sure that only one checkbox is checked at a time

$(this).parent().siblings().children().filter(':checked').not(this).removeAttr('checked');