title: Using appendTo and Load in click function
body: <p>jQuery newb and first poster. Please be gentle :-) I've searched and can't find an answer, but I'm sure there's a really simple solution.</p>
  
  <p>Hoping someone can help me. Here's what I'm trying to achieve: I have a row of tabs, with all but the first tab using a click function to load() the external page into the required div. The first tab  will have its content loaded by default, not from an external file but from a div already on the page, but further down the code for SEO reasons.</p>
  
  <p>Clicking any other tab loads the content from the external page into the div but if you then want to go back to tab 1, the content is unavailable as it's been replaced by content from the load() - ie no longer in the DOM.</p>
  
  <p>I suppose I could appendTo a #temp div before calling the load() and then append back if tab 1 link is clicked, but there must be a more elegant solution?</p>
  
  <p>Here's code so far:</p>
  
  <pre><code>$(document).ready(function(){
  
      // default tab1 content div appended to containing div OK
      $("#innerDiv1").appendTo("#outerDiv");
  
      // tab2 link loads page2.html OK
      $("#link2").click(function(){
          $("#outerDiv").load("page2.html");
      });
  
      // This doesn't work as it's no longer in the DOM after #link2 clicked.
      $("#link1").click(function(){
          $("#innerDiv1").appendTo("#outerDiv");
      });
  
  });
  </code></pre>
  
  <p>Any thoughts and replies greatly appreciated.</p>
  
  <p>Thanks in advance
  M</p>