Skip to content

Commit

Permalink
Using .siblings() instead of next()
Browse files Browse the repository at this point in the history
The plugin currently looks for $elem.next() - when validation (or any other scripts) insert a new element (such as an error label) next to the <textarea> it breaks the plugin.  Searching for $elem siblings with the counterCssClass will fix this.
  • Loading branch information
wardtwits committed Mar 22, 2015
1 parent 575391b commit 87b8f37
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion jquery.charactercounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
function checkCount(element)
{
var characterCount = $(element).val().length;
var counter = options.counterSelector ? $(options.counterSelector) : $(element).next("." + options.counterCssClass);
var counter = options.counterSelector ? $(options.counterSelector) : $(element).siblings("." + options.counterCssClass);
var remaining = options.limit - characterCount;
var condition = remaining < 0;

Expand Down

0 comments on commit 87b8f37

Please sign in to comment.