dffdsfsdfs

来源:互联网 发布:深入理解软件构造系统 编辑:程序博客网 时间:2024/05/16 05:57
<div class="wordCount" id="wordCount">    <textarea placeholder="textarea还剩余字数统计"></textarea>    <span class="wordwrap"><var class="word">200</var>/200</span></div><script src="../02/js/jquery.min.js"></script><script>    $(function(){//先选出 textarea 和 统计字数 dom 节点        var wordCount = $("#wordCount"),                textArea = wordCount.find("textarea"),                word = wordCount.find(".word");//调用        statInputNum(textArea,word);    });    function statInputNum(textArea,numItem) {        var max = numItem.text(),                curLength;        textArea[0].setAttribute("maxLength",max);        curLength=textArea.val().length;        numItem.text(max-curLength);        textArea.on('input.propertychange',function () {            numItem.text(max-$(this).val().length);        });    }

0 0
原创粉丝点击