Thursday, April 18, 2013

Go to to page jQuery Script.

****Script ****
  <script type="text/javascript">
    $(function() {
        $.fn.scrollToTop = function() {
            $(this).hide().removeAttr("href");
            if ($(window).scrollTop() != "0") {
                $(this).fadeIn("slow")
            }
            var scrollDiv = $(this);
            $(window).scroll(function() {
                if ($(window).scrollTop() == "0") {
                    $(scrollDiv).fadeOut("slow")
                } else {
                    $(scrollDiv).fadeIn("slow")
                }
            });
            $(this).click(function() {
                $("html, body").animate({
                    scrollTop: 0
                }, "slow")
            })
        }
    });
    $(function() {
        $("#gototop").scrollToTop();
    });
</script>




**** HTML Code ****
<div class="gototop"><a id="gototop" style="display:none;"><img alt="" src="<?php bloginfo(template_url); ?>/images/topicon.png"></a></div>

****CSS***
#gototop{ position:fixed; bottom:40px; right:75px; cursor:pointer; }

No comments:

Post a Comment