我需要Jquery的scrollTo函数才能在此网站上工作:http://cinicraft.com/Silverman/index.html
我尝试了以下操作
$(document).ready(function()
{
$("div.btnLp3").click(function(){
$('body,html').scrollTo('#target-examples', 800, {easing:'elasout'});
});
});
而且我也尝试过:
$(document).ready(function()
{
$("div.btnLp3").click(function(){
$('html, body').animate({ scrollTop: $(window.location.hash).offset().top}, 1000);
});
});
我似乎根本无法使scrollTo
正常工作。有人有什么想法吗?这是我导入的内容:
<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>
尝试一下
$("#clickme").click(function() {
$('html, body').animate({
scrollTop: $("#wrap2").offset().top
}, 2000);
return false;
});
/*
* 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);
$("#your-div")[0].scrollTo(0, Number.MAX_SAFE_INTEGER);