Here's a simple solution using methods of combining with each other.
$("input").click(function () { $("#" + $(this).attr("class")).show().siblings('div').hide(); });
JsFiddle example (using $ ("input"))
JsFiddle example (using $ (". ClassName"))
Activating buttons may have the same class as id for the affected divs, or you can use a separate toggler class.
An important part is to use the unique function of the clicked element to map to the unique function of the switchable element.
Finally, if the switching divs are not siblings, you can adjust the selector of all of them using var divs = $("#blah1, #blah2, #blah3, ..."); and switch them using .not() .
JsFiddle example to switch without sibling divs using .not()
source share