OKAY, so I have a bunch of numbers in a div, lets say something like...
<div id="countme">7, 5, 6, 0, 3, 0, 5, 3, 3, 2, 8</div>
And I want to use JavaScript to return...
- The specific number, and
- The number of times that number occurred in the div
Example Output: "(2,0),(1,2),(3,3),(2,5),(1,6),(1,7),(1,8)"
Explained: Zero appears two times, two appears one time, three appears three times, etc...
I've tried the following...
var str = document.getElementById('countme').innerText;
var match = str.match(/7/g);
var match1 = str.match(/5/g);
alert(match.length);
alert(match1.length);
But I need it to display the number it searched for, and I need everything to be in one alert.
Any thoughts?
Thanks! :)