Guest User

Untitled

a guest
Sep 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. // a simple count of character - js with jQuery
  2. $('.countChar').bind('keyup',function(e){
  3. var that = $(this),
  4. target = that.attr('data-target'),
  5. max = that.attr('data-max'),
  6. len = that.val().length,
  7. calc = max - len;
  8. if(len > max){
  9. var val = $(this).val();
  10. $(this).val(val.substr(0, max));
  11. calc = 0;
  12. }
  13. $('.'+target).text(calc);
  14. });
Add Comment
Please, Sign In to add comment