[Solved] Applying class tags to individual JavaScript Array entries after sorting

Glen Keybit Asks: Applying class tags to individual JavaScript Array entries after sorting
I am trying to apply the same css class to each indivdual entry in the created array, but instead I am getting it apllied once to the whole array.

My Code is as follows..

Code:
    function sortballhistory() {
        var str = document.getElementById("ballhistory").innerText;
    var temp = new Array();
    // This will return an array with strings "1", "2", etc.
    temp = str.split(",");
    temp.sort(function (a, b) {  return a - b;  });
    temp = 'temp.slice(1);
    document.getElementById('ballhistorysortedarr').innerHTML = temp;

};

ballhistory innerText contains shuffled numbers 1-90 like (2, 5, 7, 76, etc) these change each page load.

I have tried 1)

Code:
temp = '<span class="smallball">' + temp.slice(1) + '</span>';
document.getElementById('ballhistorysortedarr').innerHTML = temp;

and also tried 2)

Code:
  document.getElementById('ballhistorysortedarr').innerHTML = '<span class="smallball">' + temp; + '</span>';

and also 3)

Code:
 document.getElementById('ballhistorysortedarr').innerHTML += '<span class="smallball">' + temp; + '</span>';

But non of them give the desired result of styling each entry seperatly.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.