Edit in JSFiddle

function contentGroup($controllers, $contentEls, doEach) {
	// http://stackoverflow.com/questions/4146502/jquery-selectors-on-custom-data-attributes-using-html5
  $controllers.on( "click", function(event) {
  	// Saving "$(this)" to variable for when we go into a different scope.
    var $target = $(this);
		if (doEach) {
    	// Using an .each() loop to show or hide.
      $contentEls.each(function( index ) {
        var $item = $(this);
        if ( $item.data('content') === $target.data('content') ) {
          // Open this one.
        } else {
          // Close this one.
    } else {
    	// Using jQuery selectors to decide which ones to show or hide.
			var $content = $contentEls.filter("[data-content='" + $target.data('content') + "']");

contentGroup( $('.myController'), $('.myContent'), false );
contentGroup( $('.myController2'), $('.myContent2'), true );
This set will show or hide using an .each() loop.
	<a href="#" class="myController" data-content="stuff">Stuff</a>
	<a href="#" class="myController" data-content="things">Things</a>
	<a href="#" class="myController" data-content="doodads">Doodads</a>
	<a href="#" class="myController" data-content="dinglehoppers">Dinglehoppers</a>
<div class="myContent" data-content="stuff">This is some stuff.</div>
<div class="myContent" data-content="things">Here are some things.</div>
<div class="myContent" data-content="doodads">Look at these doodads.</div>
<div class="myContent" data-content="dinglehoppers">Here is a dinglehopper.</div>


This set will show or hide using jQuery selectors.
	<a href="#" class="myController2" data-content="stuff">Stuff</a>
	<a href="#" class="myController2" data-content="things">Things</a>
	<a href="#" class="myController2" data-content="doodads">Doodads</a>
	<a href="#" class="myController2" data-content="dinglehoppers">Dinglehoppers</a>
<div class="myContent2" data-content="stuff">This is some stuff.</div>
<div class="myContent2" data-content="things">Here are some things.</div>
<div class="myContent2" data-content="doodads">Look at these doodads.</div>
<div class="myContent2" data-content="dinglehoppers">Here is a dinglehopper.
div {