title: scroll link change to top link when user scrolls
body: <p>I would like to put a link on my webpage that when it first loads is used to scroll the page down by 500px. If the page is scrolled 10px from the top i would like that link to become a back to top link. I have coded what I thought would be correct but the link appears to only link to the top. It changes from a down chevron to an up chevron when the user scrolls but it does not then reset when the page is back to the top. hope this makes sense.</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;a class="w-toplink active" href="#"&gt;&lt;i class="fa fa-chevron-down"&gt;&lt;/i&gt;&lt;/a&gt;
  </code></pre>
  
  <p>CSS</p>
  
  <pre><code>.w-toplink {
  display: block;
  position: fixed;
  bottom: -50px;
  right: 30px;
  text-align: center;
  font-size: 14px;
  padding:12px;
  line-height: 48px;
  height: 28px;
  width: 35px;
  border-radius: 5px;
  z-index: 100;
  -webkit-transition: background-color 0.3s, opacity 0.3s, bottom 0.3s;
  transition: background-color 0.3s, opacity 0.3s, bottom 0.3s;
  background-color: #333;
  background-color: rgba(0, 0, 0, 0.3);
  color: #fff;
  opacity:0; 
  transition: opacity 200ms ease-in;
  }
  
  .w-toplink.active {
  bottom: 30px;
  opacity: 0.7;
  }
  
  .w-toplink:hover {
  opacity: 1;
  }
  
  .down-link {
      width:100%;
      height:50px;
      position:fixed;
  }
  
  #w-downlink i {
      line-height: 42px;
      font-size: 24px;
      color: #fff;
      display: block;
      width: 24px;
      margin: 0 auto;
      margin-top:10px;
  }
  
  #w-downlink {
      height: 60px;
      width: 60px;
      background-color: #191919;
      background-color: rgba(20, 20, 20, 0.4);
      position:absolute;
      bottom:0;
      margin-bottom:30px;
      right:0;
      margin-right:20px;
      cursor: pointer;
      -webkit-transform: translate3d(0, 0, 0);
      opacity: 1;
  }
  
  .w-downlink:hover {
      height: 60px;
      width: 60px;
      background-color: #191919;
      background-color: rgba(20, 20, 20, 0.4);
      position:absolute;
      bottom:0;
      margin-bottom:30px;
      right:0;
      margin-right:20px;
       cursor: pointer;
      -webkit-transform: translate3d(0, 0, 0);
      opacity: 0.5;
  }
  
  .w-toplink
  
  {opacity:0; transition: opacity 200ms ease-in;}
  .w-toplink.active{opacity:0.7;}
      .w-toplink:hover{opacity:1;}
  </code></pre>
  
  <p>JQUERY</p>
  
  <pre><code>$(window).scroll(function() {
    var scrollDownLink = $('.w-toplink');
    if ($(window).scrollTop() &lt; 5) {
      scrollDownLink.attr('href', '#about');
      scrollDownLink.find('i').removeClass('fa fa-chevron-down').addClass('fa fa-chevron-up');
    } else {
      scrollDownLink.attr('href', '#top-anchor');
      scrollDownLink.find('i').removeClass('fa fa-chevron-down').addClass('fa fa-chevron-up');
    }
  });
  </code></pre>