[英]Website Not Scrolling Down to Or displaying #proceed Div At the Right Time
Here is the JSFiddle: http://jsfiddle.net/dAQrE/ 这是JSFiddle: http : //jsfiddle.net/dAQrE/
At the top of the javascript section you will see code that is suppose to scroll down to the #proceed
div after the animation when it says: 在javascript部分的顶部,您将看到以下代码,该代码假定在动画结束后向下滚动到#proceed
div:
line 1, line 2, line 3, line 4.. 第1行,第2行,第3行,第4行。
proceed div that the page is suppose to scroll to: 继续div,页面应该滚动到:
<div id="proceed">
<div id="if_one"> <a href="http://websitelinkhere.com/1" class="button_primary agree">If Question 1 = Answer 1</a>
</div>
<div id="if_two"> <a href="http://websitelinkhere.com/2" class="button_primary agree">If Question 1 = Answer 2</a>
</div>
<div id="if_three"> <a href="http://websitelinkhere.com/3" class="button_primary agree">If Question 1 = Answer 3</a>
</div>
</div>
The javascript that is suppose to scroll to the #proceed
div after the animation: 假定在动画之后滚动到#proceed
div的javascript:
// assign the correct target
var target = $('#proceed');
$('html, body').animate({
scrollTop: target.offset().top
}, 200);
// scroll!
$('html, body').animate({
scrollTop: target.offset().top
}, 200, function () {
target.css({
'border-color': 'red'
})
});
But right now its displaying the content within the #proceed div before the animation finishes and it doesn't scroll down at all.. How do I fix this? 但是现在,它在动画结束之前在#proceed div中显示内容,并且根本不会向下滚动。如何解决此问题?
Those functions will get called on document.ready as you have them written. 在编写它们时,这些函数将在document.ready上调用。 They need to be encapsulated within a function that gets called after "line 1, line 2..." gets displayed. 它们需要封装在一个函数中,该函数在显示“第1行,第2行...”之后被调用。
I have forked your fiddle to do this. 我已经分叉了你的小提琴来做到这一点。 Check out your events which I wrapped in a function called proceed()
, and the changes I made to verifyAnimation()
to call that function after the last "line x" is displayed. 检查您包装在名为proceed()
的函数中的事件,以及在显示最后一个“ x线”之后,我对verifyAnimation()
所做的更改以调用该函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.