-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesigns.js
41 lines (34 loc) · 1008 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
// Select color input
// Select size input
var height, width, color;
// When size is submitted by the user, call makeGrid()
$('#sizePicker').submit(function(event) {
event.preventDefault();
//height
height = $('#inputHeight').val();
//width
width = $('#inputWeight').val();
makeGrid(height,width);
//console.log('Height: '+height+' and width: '+ width);
})
function makeGrid(height, width) {
//clear table
$('tr').remove();
// Your code goes here!
//for loop for height and width
for (var i = 1; i <= height; i++) {
$('#pixelCanvas').append('<tr id=table' + i + '></tr>');
for (var j = 1; j <= width; j++) {
$('#table' + i).append('<td></td>');
}
}
//add color to cell
$('td').click(function addColor() {
color = $('#colorPicker').val();
if ($(this).attr('style')) {
$(this).removeAttr('style')
} else {
$(this).attr('style', 'background-color:' + color);
}
})
}