> if($(obj).attr('checked')) { // Hide the correct answers? > $('.quizsubheader').hide('slow'); > } else { > $('.quizsubheader').show('slow'); > }; > > What's the best one-liner method to achieve the same result above? > > > > >($(obj).attr('checked')) ? $('.quizsubheader').hide('slow') : >$('.quizsubheader').show('slow');
Even shorter: $(".quizsubheader")[$(obj).attr('checked') ? 'hide' : 'show']('slow'); -Dan