I'm trying to give each td with the class '.m' a value from the array.
i.e. the first cell is given first number from the array, the second cell is given the second number etc.
The problem is that all of the cells are being given the same value of '1'
Any help is much appreciated.
Here is what I've tried so far:
JsFiddle: https://jsfiddle.net/Fraser_M/8cs5tcav/2/
HTML:
<table>
<tr>
<td class='m'></td>
<td class='m'></td>
<td class='m'></td>
<td class='m'></td>
<td class='m'></td>
<td class='m'></td>
</tr>
<tr>
<td class='m'></td>
<td class='m'></td>
<td class='m'></td>
<td class='m'></td>
<td class='m'></td>
<td class='m'></td>
</tr>
</table>
JS:
$(function() {
var myArray = [1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1];
var myArrayLength = myArray.length;
for (var i = 0; i < myArrayLength; i++) {
$('.m').text(myArray[i]);
}
});