Recommended reading: A tool to count the occurrences of strings in jquery
Nonsense not much to say, directly to everyone paste JS code.
Gets the maximum number of occurrences in the string and how many times it appears
var str = ' ASDFSSAAASASASASAA ';//define string
var json = {};//define the number of the array used to store each character element for
( var i = 0; i < str.length; i++) {//traversal of all elements in the string
if (!json[str.charat (i)]) {//To determine whether the current element already exists in the array str.charat (i)//Current element
Json[str.charat (i)] = 1; Assign the number of the corresponding array element
}
else
{
Json[str.charat (i)]++;//To assign values to the number of elements in the array}
;
var iMax = 0;//occurrences
of var iindex = ';//element name for
(var i in JSON) {//re-assign the most data and number
if (Json[i]>imax) {
iMax = json[i];
Iindex = i
}
}
Alert (' The most frequent occurrence is: ' +iindex+ ' appears ' +imax+ ' time ');
The above code is a small series of jquery to introduce you to get the most number of strings, the code is simple to understand, there are no clear welcome to my message, I will be in time to get in touch with you.