lundi 8 février 2016

Select random number from string of 1's and 0's and change color

I have a string of random 1's and 0's displayed via jQuery. I would now like to select a random number and change it's color. Is it better to work with an array, or a $(div).text() string? I can grab a number from either, but how do I insert it back into the div?

 var numbArray = [];

 for(i=0; i<10; i++)
 {
   var randomNumbers = Math.round(Math.random());
   $('#numbs').prepend(randomNumbers);
   numbArray[i] = randomNumbers;
 }

<div id="numbs">0000110111 </div>

The div above is the result of the code, but how do I select a random item, change its color, and display in the original output?

Thanks,




Aucun commentaire:

Enregistrer un commentaire