> I have a group of checkboxes, and as long as any one of > the boxes is checked I need a function bound to a select > list, but anytime none of the boxes are checked I need the > function unbound. What I have below binds and unbinds, > but if I select lets say 4 checkboxes the function is bound > and called 4 times when I change my select list. How do > I just bind it once? > > $('[EMAIL PROTECTED]').click(function(){ > if($("[EMAIL PROTECTED]'label_checkbox']").is(":checked")) { > $('#label').bind('change', function(){ > alert('test'); > }); > } else { > $('#label').unbind('change'); > } > });
I would bind the event once, then look at the check boxes when the event occurs. $('#label').bind('change', function(){ if($("[EMAIL PROTECTED]'label_checkbox']").is(":checked")) { alert('test'); } }); _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/