我需要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>
发布于 2013-09-12 10:40:45
尝尝这个
$("#clickme").click(function() {
$('html, body').animate({
scrollTop: $("#wrap2").offset().top
}, 2000);
return false;
});
发布于 2014-04-10 18:10:25
/*
* ScrollToElement 1.0
* Copyright (c) 2009 Lauri Huovila, Neovica Oy
* lauri.huovila@neovica.fi
* 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);
发布于 2020-03-26 10:20:03
$("#your-div")[0].scrollTo(0, Number.MAX_SAFE_INTEGER);
https://stackoverflow.com/questions/18754050
复制相似问题