利用jquery实现内容回滚

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="jQueryApplication._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://ajax.goolgeapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
    </script>
    <script type="text/javascript">
        $(function() {
            var $tb = $('textarea[id$=tb1]');
            $('input[id$=btnScroll]').toggle(
            function(e) {
                e.preventDefault();
                scrollArea($tb, $tb[0].scrollHeight);
            },
            function(e) {
                e.preventDefault();
                scrollArea($tb, 0);
            });
        });

        function scrollArea(ctrl, ht) {
            ctrl.animate({scrollTop: ht},1000);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div >
        <asp:TextBox ID="tb1" runat="server" TextMode="MultiLine" Text="asfasf  asfasfasfasf  asfasfasfasf  asfasfasfasf  asfasfasfasf  asfasfasfasf  asfasfasfasf  asfasfasfasf  asfasfasfasf  asfasfasfasf  asfasf"
            rows ="5"></asp:TextBox>
        <br />
        <asp:Button runat="server" Text="scroll" ID="btnScroll" />
    </div>
    </form>
</body>
</html>

 

posted @ 2010-03-22 10:43  smodi  阅读(892)  评论(0编辑  收藏  举报