我写过这个简单的旋转木马.目前我正在使用setInterval以一定的时间间隔运行我的nextSlide函数.我想在用户点击导航链接一段时间后推迟计时器的运行.
在这里查看 http://jsbin.com/uzixi3/3/edit
关于如何编写其余部分的任何反馈都会很好.
我有一个DIV我想要滚动页面,但它在折叠上方不可见所以我正在使用它.
$(window).scroll(function() {
// Get scrolling position of document
var scrollYpos = $(document).scrollTop();
// if its more than the top of the element
if (scrollYpos > 551 ) {
// Add a margin to the top
$('#scrollingDiv').animate({'margin-top': scrollYpos - 541 }, {duration: 300, queue: false});
} else {
$('#scrollingDiv').animate({'margin-top': 0 }, {duration: 200, queue: false});
}}); // end scroll
Run Code Online (Sandbox Code Playgroud)
ATM我手动给它DIV的垂直位置(551px).我想动态地做.
var elYpos = $('#scrollingDiv').offset().top
Run Code Online (Sandbox Code Playgroud)
因此,这会在页面上找到元素的垂直位置,但是当元素移动时,这会改变其他元素.
我怎样才能获得元素的位置一次?
jquery ×2