-
Notifications
You must be signed in to change notification settings - Fork 0
/
designs.js
34 lines (29 loc) · 958 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
// 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 = $('#inputHeight').val(); // Take input for height
width = $('#inputWeight').val(); // Take input for width
makeGrid(height, width);
})
function makeGrid(m, n) {
$('tr').remove(); // remove extisting tables if any
// Your code goes here!
for(var a = 1; a<= m; a++) {
$('#pixelCanvas').append('<tr id=table' + a + '></tr>');
for(var b = 1; b <= n; b++) {
$('#table' + a).append('<td></td>');
}
}
// add color pixel
$('td').click(function addColor() {
color = $('#colorPicker').val();
if ($(this).attr('style')) {
$(this).removeAttr('style')
} else {
$(this).attr('style', 'background-color:' + color);
}
})
}