Wednesday, 9 October 2013

Tombol Back ToTop versi 2

#top {cursor:pointer;background:#BAA68E;position:fixed !important;position:absolute;bottom:-30px;right:-30px;z-index:999;
height:28px;width:30px;color:#E1D4C0;font-weight:500;text-decoration:none;text-align:center;line-height:30px;-webkit-border-radius:10px 0px 0px 0px;-moz-border-radius:10px 0px 0px 0px;-o-border-radius:10px 0px 0px 0px;-ms-border-radius:10px 0px 0px 0px;border-radius:10px 0px 0px 0px;}
<a href='#' id='top'>Back To Top</a>
<script type='text/javascript'>
$(function() {
    $(&#39;#top&#39;).click(function() {
        $(&#39;html, body&#39;).animate({scrollTop:0},800)
                .animate({scrollTop:25},200)
                .animate({scrollTop:0},150)
                .animate({scrollTop:10},100)
                .animate({scrollTop:0},50);
        return false;
    });
});

$(window).scroll(function(){
 if($(this).scrollTop()&gt;200){
  $(&quot;#top&quot;).removeAttr(&quot;href&quot;);$(&quot;#top&quot;).stop().animate({
bottom:&quot;0&quot;,right:&quot;0&quot;},{duration:200, queue:false})
}else{
$(&quot;#top&quot;).stop().animate({bottom:&quot;-30&quot;,right:&quot;-30&quot;},{
duration:200,queue:false})}});
</script>

0 comments:

Post a Comment

Harta berharga adalah nasehat yang baik. Pembaca yang baik akan memberikan nasehat yang baik.

Top