Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // a simple count of character - js with jQuery
- $('.countChar').bind('keyup',function(e){
- var that = $(this),
- target = that.attr('data-target'),
- max = that.attr('data-max'),
- len = that.val().length,
- calc = max - len;
- if(len > max){
- var val = $(this).val();
- $(this).val(val.substr(0, max));
- calc = 0;
- }
- $('.'+target).text(calc);
- });
Add Comment
Please, Sign In to add comment