• 输入框输入字数限制


    <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 + "字");
         })
    
    
     });
  • 相关阅读:
    MongoDB 安装及其配置
    hdu 1241 Oil Deposits
    2014ACM/ICPC亚洲区北京站
    hdu 5901 count prime & code vs 3223 素数密度
    hdu 2191 珍惜现在,感恩生活
    FOJ 2181 快来买肉松饼
    hdu 5384 Danganronpa
    hdu 2222 Keywords Search
    hdu 1300 Pearls
    2016.2.24. 《构建之法》开始阅读
  • 原文地址:https://www.cnblogs.com/phpfensi/p/7298499.html
Copyright © 2020-2023  润新知