I'm trying to create a JavaScript code segment with JQuery which has random numbers that are constantly changing and will show in different text boxes.
However, I can't figure out how to make the numbers show different values for each text box. How can I accomplish this?
Here is my JavaScript code so far:
var pcount = $(".pcount");
for(var i= 0; i < pcount.length; i++){
var n = [];
var element = pcount.eq(i);
setInterval(function() {
n[i] = 10 + Math.floor(Math.random(Number($( ".pcount" ).val())) * 10);
$('.pcount').val(n[i]);
}, 1000);}
Here is the HTML code for the text boxes:
<input type="text" class="pcount pc1" value="10"/>
<input type="text" class="pcount pc2" value="13"/>
<input type="text" class="pcount pc3" value="16"/>