If I do this:
$('.classname').html(Math.floor(Math.random()*10)+1);
All of “classname” is filled with the same number.
Is it possible to fill every instance of “classname” with a different random number?
The only possible way I can think of solving this is to go through each instance of “class name” and apply a random number one by one.
the html method has an “overload” that accepts a function. The function should return the value to set the inner html to. In your case you can do:
the function is actually called with two arguments. The first is the index of the element in the selection and the second is the current value of the elements inner html