如何动态向下滚动页面 [英] how to dynamically scroll down pages

查看:65
本文介绍了如何动态向下滚动页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用asp.net c#创建了一个博客网站。我在索引页面上有一个链接'5条评论'。我希望当点击此链接然后重定向到评论页面并自动向下滚动到评论部分。 plz help

解决方案

假设您在页面的最底部有注释部分,因此在加载页面时,您必须使用jquery scrollTop向下滚动到注释部分。

这是一个带有jquery的示例html代码供您使用,它会自动滚动到评论区域,动画很流畅。



< pre lang =xml> < html >
< script src = http:// ajax。 googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js\"> < / script >
< script >


(document).ready(function(){


('html,body')。animate({
scrollTop:


I made a blogging web site using asp.net c#. I have a link '5 comments' on index page. I want that when this link clicked then redirect to comments page and automatically scroll down to comments section. plz help

解决方案

Suppose you have comment section at the very bottom of your page, so while you load the page you have to scroll down to comment section using jquery scrollTop.
Here is a sample html code with jquery for your help, it will automatically scroll to comment area with a nice smooth animation.

<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>


(document).ready(function () {


('html, body').animate({ scrollTop:


这篇关于如何动态向下滚动页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆