zoukankan      html  css  js  c++  java
  • 输入框输入字数限制

    <h2>亲,说说你在做什么,想什么</h2>
    <div id="div_editor">
        <textarea id="txt_content" rows="2" cols="10"></textarea>
        <div class="d-last">还能输入140字</div>
    </div>
    <input type="button" id="btn_submit" value="确定">
    h4 {
        color:#B1B1B1;
        font-weight:100;
        font-size:14px;
    }
    #div_editor {
        width:400px;
        border:1px solid #A9A9A9;
    }
    #div_editor textarea {
        border:0px;
        width:398px;
        height:45px;
        outline:0px;
        resize:none;
    }
    #div_editor div.d-last {
        text-align:right;
        font-size:10px;
        color:#B1B1B1;
        display:none;
    }
    #btn_submit {
        color:white;
        background-color:#8AC328;
        width:80px;
        height:25px;
        border:1px solid #9CC868;
        margin:1px;
    }
    $(function() {
    
         $("#div_editor textarea").focus(function() {
    
             $(this).css("height", "60px");
             $("#div_editor div.d-last").show();
             $("#div_editor").css("borderColor", "#B4E6FA");
    
         }).blur(function() {
    
             $(this).css("height", "45px");
             $("#div_editor div.d-last").hide();
             $("#div_editor").css("borderColor", "#A9A9A9");
    
         }).keyup(function() {
    
             var c = $(this).val();
             if (c.length > 140) {
                 c = c.substr(0, 140);
                 $(this).val(c);
             }
             var last = 140 - c.length;
             $("#div_editor div.d-last").text("还能输入" + last + "字");
         })
    
    
     });
  • 相关阅读:
    MySQL大表优化方案
    写一个简单脚本检测mysql主从是否正常
    Nginx配置基于ip的虚拟主机
    推荐一些好的linux学习网站
    shell基础入门(一)
    centos7和linux防火墙配置入门
    centos7.0之vsftpd随笔
    获取系统相关属性
    linux 文件管理操作入门
    ANSI文件操作
  • 原文地址:https://www.cnblogs.com/phpfensi/p/7298499.html
Copyright © 2011-2022 走看看