thanks Dave and Ricardo!
On Dec 18, 12:00 am, Ricardo Tomasi <ricardob...@gmail.com> wrote: > var $check = $(':checkbox'); > $check.change(function(){ > $('#special')[ $check.attr('checked') ? 'show' : 'hide' ]('slow'); > > }); > > that's essentially the same as > > $check.attr('checked') ? $('special').show('slow') : $('special').hide > ('slow'); > > (which is an if/else). And you don't need the IDs on the inputs. > > - ricardo > > On Dec 18, 12:58 am, "krozi...@gmail.com" <krozi...@gmail.com> wrote: > > > Folks, > > > I have two checkboxes. When either one is checked, I would like to > > show a div. When both are not checked, then I want the div hidden. > > However, I've only been able to use toggle to show and hide the div > > only when checking/unchecking one checkbox. It's not quite what I > > need. So far I have this: > > > js: > > $("#check_1").click(function(){ $("#special").toggle("slow"); }); > > $("#check_2").click(function(){ $("#special").toggle("slow"); }); > > > html: > > <input type="checkbox" id="check_1" name="check_options[]" value="1" /> One > > <br /> > > > <input type="checkbox" id="check_2" name="check_options[]" value="2" / > > > > Two <br /> > > > <div id="special"> > > Some special stuff... > > </div> > > > Any help would be appreciated. > > > Thanks, > > Konstantin