commadelimited/textCounter.js

语言: JavaScript

git: https://github.com/commadelimited/textCounter.js

一个jQuery插件,提供输入字段中的文本倒计时。
A jQuery plugin which provides a countdown of text in an input field.
README.md (中文)

textCounter.js

TextCounter是一个jQuery插件,它提供输入字段中的文本倒计时。受Twitter推断推文中剩余字符的方式的启发,textCounter是一个可配置的jQuery插件,可以轻松地允许任何人添加相同的功能。考虑到最佳实践,textCounter提供多个字符计数范围,通过CSS类自定义着色,甚至能够防止用户超出字符数限制。

查看textCounter的简单演示

快速开始

克隆git repo - git clone https://github.com/commadelimited/textCounter.js.git - 或下载它

用法和文档

$(function(){
    $('#theCounter').textCounter({
        target: '#myTextarea' // required: string
    });
});

$(function(){
    $('#theCounter').textCounter({
        target: '#myTextarea', // required: string
        count: 70, // optional: if string, specifies attribute of target to use as value
                   //           if integer, specifies value. [defaults 140]
        alertAt: 20, // optional: integer [defaults 20]
        warnAt: 10, // optional: integer [defaults 0]
        stopAtLimit: false // optional: defaults to false
    });
});

特约

邀请您为此项目提供代码和建议。多多益善。

项目信息/许可证

  • 来源:https://github.com/commadelimited/textCounter.js

第三方图书馆要求:

  • jQuery:MIT / GPL许可证

自定义位:

与GPL

Bitdeli Badge

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

textCounter.js

TextCounter is a jQuery plugin which provides a countdown of text in an input field. Inspired by the way Twitter counts down the remaining characters in a tweet, textCounter is a configurable jQuery plugin that easily allows anyone to add this same functionality. Written with best practices in mind, textCounter offers multiple character count ranges, custom coloration via CSS classes, and even the ability to prevent users from exceeding the character count limit.

Example

View a simple demo of textCounter

Quick start

Clone the git repo - git clone https://github.com/commadelimited/textCounter.js.git - or download it

Usage & Documentation

$(function(){
    $('#theCounter').textCounter({
        target: '#myTextarea' // required: string
    });
});

$(function(){
    $('#theCounter').textCounter({
        target: '#myTextarea', // required: string
        count: 70, // optional: if string, specifies attribute of target to use as value
                   //           if integer, specifies value. [defaults 140]
        alertAt: 20, // optional: integer [defaults 20]
        warnAt: 10, // optional: integer [defaults 0]
        stopAtLimit: false // optional: defaults to false
    });
});

Contributing

You are invited to contribute code and suggestions to this project. The more the merrier.

Project Info / License

3rd party libraries required:

  • jQuery: MIT/GPL license

Custom bits:

MIT GPL

Bitdeli Badge