Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Countable is a JavaScript function to add live paragraph-, word- and character-counting to an HTML element.
Branch: master
Pull request Compare This branch is 96 commits behind RadLikeWhoa:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
CONTRIBUTING.md
Countable.js
LICENSE.md
README.md

README.md

Countable

Countable is a JavaScript function to add live paragraph-, word- and character-counting to an HTML element. Countable does not rely on any libraries and is very small in size.

View the Demo

Usage

You can define your own callback function that Countable should use. If you don't pass such a function, the results are simply logged to the console.

<script src="js/Countable.js"></script>
<script>
  new Countable(elem, function (counter) {
    alert(counter.paragraphs, counter.words, counter.characters);
  });
</script>

Countable takes the value from an HTML element and counts paragraphs, words and characters. Those numbers are then returned in an object, accessible by a single parameter in the callback function. In the above example, counter holds all numbers returned from Countable.

Browser Support

Countable has been tested in Chrome (latest), Safari (latest), Firefox (latest), Opera (latest) and Internet Explorer (7+). It is built to support both newer and older browsers. Should you find an error, please submit an isssue describing the error, including your browser version and operating system.

About the Author

My name is Sacha Schmid. I'm a front-end engineer from Switzerland. I am the creator of SSGS and other open source projects.

Something went wrong with that request. Please try again.