title: jQuery replaceWith works only once
body: <p>I'm trying to replace one element with another. It works only once, then when I try to click the element <code>.two</code> again, it doesn't call the function. </p>
  
  <p>This is the code, its wrapped around a django for loop. That's why I need to use <code>$(this)</code>:</p>
  
  <pre><code>&lt;div class = "galery"&gt;
  
  {% for image in images %}
  
  &lt;img class = 'one' src = "http://www.fmscout.com/datas/avatars/48327-chelsea-logo.jpg"&gt;
  &lt;span class='glyphicon glyphicon-certificate two'&gt;&lt;/span&gt;
  
  {% endfor %}
  
  &lt;/div&gt;
  
  &lt;script&gt;
  $('.two').on('click', change_content);
  
  function change_content(){
      var one = $('.galery').find('.one')
      $(this).replaceWith("&lt;img class = 'one' src ='http://www.fmscout.com/datas/avatars/48327-chelsea-logo.jpg'&gt;")
      one.replaceWith("&lt;span class='glyphicon glyphicon-certificate two'&gt;&lt;/span&gt;")
  }
  
  &lt;/script&gt;
  </code></pre>