title: How to make onload script work again after content changed
body: <p>I have a page where you select between 2 pictures, when you click one of them, the content of the div changes. The new content also has 2 pictures which will load another content when clicked. I am using javascript, but the script only loads once, so when I get to the second content, it doesn't change anymore.</p>
  
  <p>I got 3 files:</p>
  
  <p>Main.html - content1.html - content2.html - script.js</p>
  
  <p>Main.html:</p>
  
  <pre><code>&lt;div id="change"&gt;
      &lt;div id="rightside"&gt;            
          &lt;img src="img.jpg" class="class1" id="water" alt="right choice"&gt;
      &lt;/div&gt;
      &lt;div id="leftside"&gt;
          &lt;img src="img2.jpg" class="class1" id="water2" alt="left choice"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;script type="text/javascript" src="../js/script.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Here is the content that will be replaced in the class change:
  content1.html:</p>
  
  <pre><code>&lt;div id="rightside"&gt;            
    &lt;img src="img3.jpg" class="class1" id="water3" alt="right choice"&gt;
  &lt;/div&gt;
  
  &lt;div id="leftside"&gt;
      &lt;img src="img4.jpg" class="class1" id="water4" alt="left choice"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>this is the content that i want to replace on the next click:
  content2.html:</p>
  
  <pre><code>&lt;div id="rightside"&gt;            
    &lt;img src="img5.jpg" class="class1" id="water5" alt="right choice"&gt;
  &lt;/div&gt;
  
  &lt;div id="leftside"&gt;
      &lt;img src="img6.jpg" class="class1" id="water6" alt="left choice"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is the script that suppose to do that:</p>
  
  <pre><code>window.onload = function() {
  
      document.getElementById("water").onclick = function() 
      {
          $('#change').load('content1.html');
  
      };
  
      document.getElementById("water3").onclick = function() {
          $('#change').load('content2.html');
  
      };
  </code></pre>
  
  <p>If I click the image with id water, it replace with content1, then I click the image with water3, nothing happens</p>