Simple Twitter-Like jQuery Character Counter Plugin

Simple Twitter-Like jQuery Character Counter Plugin
File Size: 94.4 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Just another character counter plugin which allows you to count and limit characters in an DIV container, similar to the Twitter's tweet box.

See also:

How to use it:

1. Load the required style.css in the header to style the plugin.

<link rel="stylesheet" href="src/style.css">

2. Create an DIV element in your document.

<div id="demo"></div>

3. Load jQuery library and the JQuery counter plugin at the bottom of the document.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="src/jquery-counter.0.1.0.js"></script>

4. Call the plugin with default options.

$(document).ready(function(){
  $('#demo').counter();
});

5. Optional settings.

  • limit: 140: Maximum character count.
  • limitWarning: 25: Number indicate where warning limit is on.
  • limitElement: 'span': Inline HTML element to show the left numbers of characters.
  • counterClass:   'counter': Class to decorate counter element .
  • limitClass: 'limit': Class to decorate limit element.
  • warningClass: 'warning':  Class to decorate limit element in case of warning. 
  • exceededClass: 'exceeded': Class to decorate limit element in case of exceed of characters. 
  • format: '%1': Format the output to show the rest of the characters.
  • onInit: function() {}: callback
  • onDestroy: function() {}: callback

This awesome jQuery plugin is developed by ravikumar8. For more Advanced Usages, please check the demo page or visit the official website.