-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava.js
33 lines (30 loc) · 963 Bytes
/
java.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();
width = $('#inputWeight').val();
makeGrid(height, width);
//console.log('Height: ' + height + 'and width: ' + width);
})
function makeGrid(x, y) {
$('tr').remove();
// Your code goes here!
for (var i = 1; i <= x; i++){
$('#pixelCanvas').append('<tr id=table' + i + '></tr>');
for (var j = 1; j <=y; 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);
}
})
}