A jQuery plugin which provide character counter similar to Twitter.
Used jQuery plugin boilerplate from JONATHAN NICOL :) Thanks!
Include script after the jQuery library
<script src="/path/jquery-counter.min.js"></script>
html
<div id="tweet-template"></div>
jQuery
$('#tweet-template').counter();
$('#tweet-template').counter({
limit: 140,
limitWarning: 25,
limitElement: 'span',
counterClass: 'counter',
limitClass: 'limit',
warningClass: 'warning',
exceededClass: 'exceeded',
format: '%1'
});
- limit: Maximum character count. Default 140
- limitWarning: Number indicate where warning limit is on. Default 25
- limitElement: Inline HTML element to show the left numbers of characters. Default span
- counterClass: Class to decorate counter element . Default counter
- limitClass: Class to decorate limit element. Default limit
- warningClass: Class to decorate limit element in case of warning. Default warning
- exceededClass: Class to decorate limit element in case of exceed of characters. Default exceeded
- format: Format the output to show the rest of the characters. Default %1
- input text and textarea support
- word count
- Callback Support
- Bug fixes if any
- JSLinting & Testing
Released under the MIT license
Copyright (c) 2014 Ravi Kumar