• 文本域高度的动态变化


    HTML:
    <!DOCTYPE >

    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <style type="text/css">
    * {
    /*margin: 0px;
    padding: 0;*/
    font-family: "微软雅黑", "arial", " sans-serif";
    font-size: 16px;
    }

    body {
    margin: 20px;
    }
    </style>
    <script type="text/javascript" src="js/jquery-2.2.2.min.js">
    </script>

    <script type="text/javascript">
    $(function () {
    var oComment = $("#comment");
    $(".bigger").click(function () {
    if (!oComment.is(":animated")) {
    if (oComment.height() < 500) {
    oComment.animate({height: "+=50"}, 400);
    }
    }
    })

    $(".smaller").click(function () {
    if (!oComment.is(":animated")) {
    if (oComment.height() > 50) {
    oComment.animate({height: "-=50"}, 400);
    }
    }
    })


    });
    </script>
    </head>

    <body>
    <form action="" method="post">
    <div class="msg">
    <div class="msg_caption">
    <span class="bigger">向下(+)</span>
    <span class="smaller">向上(-)</span>
    </div>
    </div>
    <textarea id="comment" rows="8" cols="25">
    在线文本编辑器.在线文本编辑器.在线文本编辑器.
    在线文本编辑器.在线文本编辑器.在线文本编辑器.
    在线文本编辑器.在线文本编辑器.在线文本编辑器.
    在线文本编辑器.在线文本编辑器.在线文本编辑器.

    </textarea>
    </form>

    </body>

    </html>

    result:

    运行:

  • 相关阅读:
    模板:高精度求积
    模板:求n累加和
    模板:求A/B高精度值
    模板:堆
    模板:素数筛
    模板:前缀和
    模板:单调队列(Sliding Window)
    模板:最长上升子序列(LIS)
    [转]Asp.net mvc 网站之速度优化 -- 页面缓存
    [转]ASP.NET MVC3 + EF 性能优化解决方案以及最优架构
  • 原文地址:https://www.cnblogs.com/theWayToAce/p/5497875.html
Copyright © 2020-2023  润新知