Multiple Instances of Jquery WordCount

Trying to use the jquery wordcount plugin on multiple instances of textareas on my site.   Missing something obvious.  The first one works but the rest do not.

<script type="text/javascript">
/**
 * jQuery.textareaCounter
 * Version 1.0
 * Copyright (c) 2011 c.bavota - http://bavotasan.com
 * Dual licensed under MIT and GPL.
 * Date: 10/20/2011
**/
(function($){
	$.fn.textareaCounter = function(options) {
		// setting the defaults
		// $("textarea").textareaCounter({ limit: 100 });
		var defaults = {
			limit: 300
		};	
		var options = $.extend(defaults, options);
 
		// and the plugin begins
		return this.each(function() {
			var obj, text, wordcount, limited;
			
			obj = $(this);
			obj.after('<span style="font-size: 11px; clear: both; margin-top: 3px; display: block;" id="counter-text">Max. '+options.limit+' words</span>');

			obj.keyup(function() {
			    text = obj.val();
			    if(text === "") {
			    	wordcount = 0;
			    } else {
				    wordcount = $.trim(text).split(" ").length;
				}
			    if(wordcount >= options.limit) {
			        $("#counter-text").html('<span style="color: #DD0000;">0 words left</span>');
					limited = $.trim(text).split(" ", options.limit);
					limited = limited.join(" ");
					$(this).val(limited);
			    } else {
			        $("#counter-text").html((options.limit - wordcount)+' words left');
			    } 
			});
		});
	};
})(jQuery);
</script>

<script type="text/javascript">
	$("#Question_committee").textareaCounter();
	$("#Question_served").textareaCounter();
	$("#Question_fro").textareaCounter();
	$("#question_growth").textareaCounter();
	$("#servedoutside").textareaCounter();
	</script>

Open in new window


Each of the textboxes have the id listed above.
digitalwiseAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
Using v2 it works fine, maybe it wasn't possible in v1 and there is nothing in the code to suggest it can be bound to more than 1 textarea
0
digitalwiseAuthor Commented:
Do you have a link to v2?
0
GaryCommented:
Actually  I think I was looking at a different plugin :^)
http://roy-jin.appspot.com/jsp/textareaCounter.jsp

Anyway the one you are using is not programmed for multiple instances.
0
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

digitalwiseAuthor Commented:
I guess I was looking to try to adjust the code so it could handle more than one instance.  The one you are referencing doesn't do anything for me - I need to limit the word count.
0
GaryCommented:
I will have a look at the plugin you are using and see if I can fix it a bit later
0
GaryCommented:
Change
$("#counter-text").html((options.limit - wordcount)+' words left');

to
$(this).next("#counter-text").html((options.limit - wordcount)+' words left');
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.