title: How to reverse direction of moving div once it reaches side of screen?
body: <p>I have an absolutely positioned div that uses the jQuery .animate function to move horizontally from the right to left of the screen.
  My problem is that once the div reaches the far left side, it continues and eventually disappears from the screen. How do you make it so that once the div reaches the left side, it will reverse and start going to the right? (and then vice versa so that the right side won't continue going right, but goes left again once it reaches the end)</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div class="container"&gt;
      &lt;div class="block"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>CSS:</p>
  
  <pre><code>.block {
      float:right;
      position:absolute;
      right:100px;
      width:100px;
      height:100px;
      background:red;
  }
  </code></pre>
  
  <p>jQuery:</p>
  
  <pre><code>$('.block').click(function() {
      $(this).animate(
          {"right": "+=100px"},"slow");
  });
  </code></pre>
  
  <p>Here is my JSFiddle: <a href="https://jsfiddle.net/ebkc9dzL/" rel="noreferrer">https://jsfiddle.net/ebkc9dzL/</a></p>
  
  <p>Thank you I really appreciate the help!</p>