A letter count is FAR easier - just get the string's length.

L

Rick Faircloth wrote:
Is it as simple to do a letter count?


-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf 
Of Liam Potter
Sent: Friday, July 24, 2009 6:53 AM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: How to deterine number of words in a string?


or if you really do want it as a plugin

Plugin:
(function($){
   $.fn.stringCount = function() {
var string = this.text();
        var count = string.split(" ");
        var result = count.length;
return result
   }
})(jQuery);

Use:
$(function(){
    alert( $("span.string").stringCount() );
});

Liam Potter wrote:
you don't need a plugin, this will do it

var string = $("span.string").text();
var count = string.split(" ");
alert(count.length);


Conrad Cheng wrote:
Hi all,
Any jquery plugin can check number of word in a string instead using of .length?...

Many thanks.

Conrad
------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.5.392 / Virus Database: 270.13.32/2266 - Release Date: 07/27/09 05:58:00


Reply via email to