I spit out this type of code frequently:
if ($(this).val() == 'X') { $('#something').show(); }
else { $('#something').hide(); }
I'm not crazy about having $('#something') appear twice. Is there a more elegant way of expressing this?
[Update] I phrased the question badly - I'm looking for a general solution, not just show/hide (and therefore toggle). For the general case of taking different actions on a selected element(s) based on a conditional, is there a more elegant construct?