title: modifying words count jquery function
body: <pre><code>(function($){
      $.fn.textareaCounter = function(options) {
          // setting the defaults
          // $("textarea").textareaCounter({ limit: 100 });
          var defaults = {
              limit: 150
          };  
          var options = $.extend(defaults, options);
  
          // and the plugin begins
          return this.each(function() {
              var obj, text, wordcount, limited;
  
              obj = $(this);
              obj.next(".hint").after('&lt;span style="font-size: 11px; font-weight: bold; color:#6a6a6a; clear: both; margin: 3px 0 0 150px; float: left; overflow: hidden;" id="counter-text"&gt;Max. '+options.limit+' words&lt;/span&gt;');
  
              obj.on("keyup keydown", function() {
                  text = obj.val();
                  if(text === "") {
                      wordcount = 0;
                  } else {
                      wordcount = obj.val().split(" ").length;
                  }
                  if(wordcount == options.limit) {
                      obj.next(".hint").next("#counter-text").html('&lt;span style="color: #DD0000;"&gt;0 words left&lt;/span&gt;');
                      limited = $.trim(text).split(" ", options.limit);
                      limited = limited.join(" ");
                      $(this).val(limited);
                  } else {
                      obj.next(".hint").next("#counter-text").html((options.limit - wordcount)+' words left');
                  } 
              });
          });
      };
  })(jQuery);
  </code></pre>
  
  <p>I use above jQuery function to count words that are typing in a <code>textarea</code>. At the moment its working for me. With this script I can count words in all textareas in my forms that limit to 150 words. </p>
  
  <p>But I need to apply this function to textarea to count words with different limit criteria. That mean 1 textarea with 150 words, one with 100 words, one with 60 words etc... can anybody here help me to do this modification?</p>
  
  <p>NOTE: I use this function something like this.. <code>$("textarea").textareaCounter();</code></p>