jQuery: Count occurrences of a character in a string
I have a string that is returned, that contains data separated by |'s.
I already have my script splitting by a '|', now I jus开发者_开发百科t need to count how many pieces of data are stored in the string, easiest way I see it would be to count the number of |'s in the string.
This is basically what's going on so far: http://jsfiddle.net/53ueL/
Greatly appreciate any help in advance!
I might be missing something, but I it looks like you can just do:
$(".Count").html(TOElist.length);
Why not simply get the length of the array you've split everything into?
$(".Count").html(TOElist.length);
http://jsfiddle.net/53ueL/1/
精彩评论