I have a number of message elements that come in pairs: If element A1 is shown, then A2 should be hidden, same for B1/B2, C1/C2, and so on. I have the jQuery code working, but it gets verbose:
if (conditionA) {
$("#a1").show();
$("#a2").hide();
else {
$("#a1").hide();
$("#a2").show();
}
if (conditionB) {
$("#b1").show();
$("#b2").hide();
else {
$("#b1").hide();
$("#b2").show();
}
//etc...
This seems cumbersome and mind-numbing. Is there a better way to encapsulate the notion that these elements are paired and should show/hide opposite each other? I've looked at toggle, but that isn't right.