Return to Snippet

Revision: 12403
at March 12, 2009 18:14 by joeydi


Initial Code
$('textarea').each(function(){
					// get current number of characters
					var length = $(this).val().length;
					// get current number of words
					//var length = $(this).val().split(/\b[\s,\.-:;]*/).length;
					// update characters
					$(this).parent().find('.counter').html( 4000 - length + ' characters left');
					// bind on key up event
					$(this).keyup(function(){
						// get new length of characters
						var new_length = $(this).val().length;
						// get new length of words
						//var new_length = $(this).val().split(/\b[\s,\.-:;]*/).length;
						// update
						$(this).parent().find('.counter').html( 4000 - new_length + ' characters left');
					});
				});

Initial URL

                                

Initial Description

                                

Initial Title
jQuery Character Count

Initial Tags
jquery

Initial Language
jQuery