Populate the grid dynamically

This commit is contained in:
Tissevert 2022-07-23 18:33:01 +02:00
parent c6a84321d4
commit dda80df882
4 changed files with 25 additions and 4 deletions

View file

@ -0,0 +1,3 @@
#mode {
list-style: none;
}

View file

@ -8,10 +8,10 @@
</head> </head>
<body> <body>
<ul id="mode"> <ul id="mode">
<li id="edit"></li> <li id="edit">Édition</li>
</ul> </ul>
<div id="playground"> <div id="playground">
<div id="grid"></div> <table id="grid"></table>
</div> </div>
</body> </body>
</html> </html>

18
js/Grid.js Normal file
View file

@ -0,0 +1,18 @@
import * as Dom from UnitJS.Dom;
var size = 8;
return {
init: init
}
function init(elementId) {
var gridElement = document.getElementById(elementId || 'grid');
for(var row = 0; row < size; row++) {
var cells = [];
for(var column = 0; column < size; column++) {
cells.push(Dom.make('td'));
}
gridElement.appendChild(Dom.make('tr', {}, cells));
}
}

View file

@ -1,3 +1,3 @@
import * as Dom from UnitJS.Dom; import Grid;
console.log('plip'); Grid.init();