title: Jquery Issue: Why does my alert get triggered multiple times?
body: <p>The code below takes a div and moves it on click. The return button the moves the div back to where it was before. The second alert gets triggered multiples times on occasion. Can someone explain why?</p>
  
  <pre><code>&lt;html&gt;
          &lt;head&gt;
              &lt;script src="js/jquery.js"&gt;&lt;/script&gt;
              &lt;style&gt;
  
              .profile {
  
                  width: 250px;
                  height: 250px;
                  margin-top: 250px;
                  margin-left: 250px;
                  border: solid black 1px;
              }
  
          &lt;/style&gt;
  
          &lt;/head&gt;
          &lt;body&gt;
          &lt;script&gt;
  
              $(document).ready(function(){
  
                  $('.profile').click(function(){
  
                                      // store current position
                      var activeProfile = $(this);
                      var profilePosition = activeProfile.offset();
                      var initialLeft = profilePosition.left;
                      var initialTop = profilePosition.top;
  
  
                      alert(initialLeft);
  
                      $(this).css({'position' : 'absolute', 'top' : 0, 'left' : 0, 'margin': 0});
  
                              // return to original start position
                          $('#close').click(function(e) {
                          alert('sometimes i get triggered multiple times!');
                          activeProfile.css({'left' : initialLeft, 'top' : initialTop});
                          e.stopPropagation();
  
  
                       });    
  
                  });
  
              })
  
          &lt;/script&gt;
  
              &lt;div class="profile"&gt;
                  &lt;button id="close"&gt;Return&lt;/button&gt;
              &lt;/div&gt;
  
          &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>