-
Notifications
You must be signed in to change notification settings - Fork 0
/
designs.js
46 lines (32 loc) · 929 Bytes
/
designs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Select color input
// Select size input
// When size is submitted by the user, call makeGrid()
$("#submit").on('click', makeGrid);
$('#pixelCanvas').on("click", "td", addColor)
let rows, columns, table, mainTable;
function makeGrid(e) {
e.preventDefault();
//variable declaration
//create table
table = $('#pixelCanvas');
//create rows
rows = $("#input_height").val();
//create columns
columns= $("#input_width").val();
mainTable = "";
//clear table and create new
while(table.empty()){
//loop to create table
for (let i= 1; i <= rows; i++) {
mainTable += "<tr>";
for (let j = 1; j <= columns; j++) {
mainTable += '<td></td>'
}
mainTable += "</tr>";
}
return table.append(mainTable);
}}
function addColor() {
let color = $('#colorPicker').val();
$(this).css("background-color", color);
}