title: jQuery why is this loop running twice?
body: <pre><code>$(document).bind("ready", function(){
  
      // Loop each construct tag
      $('construct').each(
              alert('running');
  
          function ()
          {
              // Grab data
              var jC2_events = $(this).html().split('\n');
              $(this).html('');
  
              // Data
              var jC2_html = '';
  
              // Add wrapper tags
              jC2_html += '&lt;div class="jC2_Outer"&gt;';
              jC2_html += '&lt;div class="jC2_Toolbar"&gt;';
              jC2_html += '&lt;a href="#" class="jC2_ToolbarA"&gt;Plain Text&lt;/a&gt;';
              jC2_html += '&lt;a href="#" class="jC2_ToolbarA"&gt;Help&lt;/a&gt;';
              jC2_html += '&lt;/div&gt;';
              jC2_html += '&lt;div class="jC2_Container"&gt;';
  
              // Loop each event
              for(var jC2_looper = 0; jC2_looper &lt; jC2_events.length; jC2_looper++)
              {           
                  // Split event into components
                  var jC2_components = jC2_events[jC2_looper].split(':');
  
                  // Event wrapper
                  jC2_html += '&lt;div class="jC2_EventNum"&gt;' + (jC2_looper + 1) + '&lt;/div&gt;'
                  jC2_html += '&lt;div class="jC2_EventWrapper"&gt;';
                      jC2_html += '&lt;div class="jC2_EventObject"&gt;' + jC2_components[0].trim() + '&lt;/div&gt;';
                      jC2_html += '&lt;div class="jC2_EventBreak"&gt;&lt;/div&gt;';
                      jC2_html += '&lt;div class="jC2_EventDesc"&gt;' + jC2_components[1].trim() + '&lt;/div&gt;';        
                  jC2_html += '&lt;/div&gt;';
  
                  // Actions
                  jC2_html += '&lt;div class="jC2_ActionWrapper"&gt;';
  
                  // Loop remaining params
                  for(var jC2_looper2 = 2; jC2_looper2 &lt; jC2_components.length; jC2_looper2++)
                  {
                      var jC2_actionClass;
                      if((jC2_looper2%2) == 0){
                          jC2_actionClass = 'jC2_Odd';
                      }else{
                          jC2_actionClass = 'jC2_Even';
                      }
  
                      jC2_html += '&lt;div class="jC2_ActionLeft"&gt;&lt;/div&gt;';
                      jC2_html += '&lt;div class="jC2_ActionDesc ' + jC2_actionClass + '"&gt;' + jC2_components[jC2_looper2].trim() + '&lt;/div&gt;';
                      jC2_html += '&lt;div class="jC2_Clear"&gt;&lt;/div&gt;';
                  }               
  
                  jC2_html += '&lt;/div&gt;&lt;div class="jC2_Clear"&gt;&lt;/div&gt;';
              }
  
              // End wrappers
              jC2_html += '&lt;/div&gt;';
              jC2_html += '&lt;div class="jC2_FooterInfo"&gt;&lt;div class="jC2_Scirra"&gt;&lt;a class="jC2_AS" href="http://www.scirra.com"&gt;Scirra.com&lt;/a&gt; - Software in Motion&lt;/div&gt;Generated with &lt;a class="jC2_AF" href="http://www.scirra.com"&gt;JConstruct 1.0&lt;/a&gt;&lt;/div&gt;';
              jC2_html += '&lt;/div&gt;';
              $(this).html(jC2_html);
          }
      );
  
  });
  </code></pre>
  
  <p>And my HTML page:</p>
  
  <pre><code>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.&lt;br /&gt;&lt;br /&gt;
  
  &lt;construct&gt;
  System:Every tick:Set width to Y-100:Set angle to Atan(Self.X-Mouse.X):Finish it
  Sprite:On event:Do this:Do that:Do something else
  Clock:Ticks and chimes:Do something:Do it again!:Add one
  &lt;/construct&gt;
  
  &lt;br /&gt;&lt;br /&gt;When an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  </code></pre>
  
  <p>I'm just trying to loop every  tag and render it's data contents as a nicely formatted HTML but am having trouble parsing the data into individual lines, and having trouble because this loop appears to be running twice when I put an alert in it.</p>