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