Link to home
Start Free TrialLog in
Avatar of Jordan Benett
Jordan Benett

asked on

Character counter breaks after adding EmojiOne Area

I have a character counter for my textarea that was working great until I added EmojiOne Area. The emoji picker now works great, but my character counter stopped working. For some reason the keyup is no longer working off of the ID.

HTML

<textarea id="message" class="form-control" placeholder="Enter text here..."></textarea> 
<label><span id="chars" class="lead">140</span></label> characters left

Open in new window


JavaScript

/*emojioneArea */
$(document).ready(function() {
  $("#message").emojioneArea({
    pickerPosition: "bottom",
    tonesStyle: "bullet"
  });
});

/*Character Counter */
function countChar(val) {
  var len = val.value.length;

  if (len >= 140) {
    val.value = val.value.substring(0, 140);
    $('#stat span').text(0);
  } else {
    $('#stat span').text(140 - len);
  }
}
countChar($('#message').get(0));
$('#message').keyup(function() {
  countChar(this);
});

Open in new window


JSFiddle.
ASKER CERTIFIED SOLUTION
Avatar of Banshi lal dangi
Banshi lal dangi
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jordan Benett
Jordan Benett

ASKER

Banshi, thank you for the solution, can you please share the Fiddle link, as I am not able to run it.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot Banshi, That worked great!