Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrollTo function jQuery is not working

I need Jquery's scrollTo function to work for this website: http://cinicraft.com/Silverman/index.html

I've tried the following

$(document).ready(function()
{
    $("div.btnLp3").click(function(){
        $('body,html').scrollTo('#target-examples', 800, {easing:'elasout'});
    });
});

And I've tried this too:

$(document).ready(function()
{
    $("div.btnLp3").click(function(){
        $('html, body').animate({ scrollTop: $(window.location.hash).offset().top}, 1000);
    });
});

I can't seem to get scrollTo working at all. Does anyone have any ideas? Here's what I have imported:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">  </script>    
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js">  </script>
like image 583
Matt Andrzejczuk Avatar asked Sep 12 '13 01:09

Matt Andrzejczuk


2 Answers

Try this

$("#clickme").click(function() {
    $('html, body').animate({
        scrollTop: $("#wrap2").offset().top
    }, 2000);
    return false;
});

FIDDLE

like image 184
Khawer Zeshan Avatar answered Oct 19 '22 08:10

Khawer Zeshan


/*
* ScrollToElement 1.0
* Copyright (c) 2009 Lauri Huovila, Neovica Oy
*  [email protected]
*  http://www.neovica.fi
*  
* Dual licensed under the MIT and GPL licenses.
*/

(function($) {
    $.scrollToElement = function($element, speed) {

        speed = speed || 750;

        $("html, body").animate({
            scrollTop: $element.offset().top,
            scrollLeft: $element.offset().left
        }, speed);
        return $element;
    };

    $.fn.scrollTo = function(speed) {
        speed = speed || "normal";
        return $.scrollToElement(this, speed);
    };
})(jQuery);
like image 3
CountZero Avatar answered Oct 19 '22 09:10

CountZero