title: Loop through Jquery function
body: <p>I have this script:</p>
  
  <pre><code>&lt;script&gt;
  $(function() {
  // run the currently selected effect
  function runEffect() {
    // get effect type from
    var selectedEffect = $( "#Puff" ).val();
  
    // most effect types need no options passed by default
    var options = {};
    // some effects have required parameters
    if ( selectedEffect === "scale" ) {
      options = { percent: 0 };
    } else if ( selectedEffect === "size" ) {
      options = { to: { width: 200, height: 60 } };
    }
  
    // run the effect
    $( "#myModal" ).toggle( selectedEffect, options, 500 );
    };
  
   // set effect from select menu value
   $( "div.notAMember a" ).click(function() {
    runEffect();
    });
    });
  
    $(function() {
    // run the currently selected effect
    function runEffect() {
    // get effect type from
    var selectedEffect = $( "#Puff" ).val();
  
    // most effect types need no options passed by default
    var options = {};
    // some effects have required parameters
    if ( selectedEffect === "scale" ) {
      options = { percent: 0 };
    } else if ( selectedEffect === "size" ) {
      options = { to: { width: 200, height: 60 } };
    }
  
    // run the effect
    $( "#myModalJoin" ).toggle( selectedEffect, options, 500 );
    };
  
     // set effect from select menu value
     $( "div.registeredMember a" ).click(function() {
    runEffect();
    });
    });
  
   &lt;/script&gt;
  </code></pre>
  
  <p>It's purpose is that when a modal is open and i click a link in it, the modal closes and a new modal is shown. I want to click a link now in the new modal and when doing so, close the open modal and open the first modal again.
  How can i loop through this modals by clicking a link on each one of them?</p>