-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakegrid.js
More file actions
29 lines (26 loc) · 724 Bytes
/
makegrid.js
File metadata and controls
29 lines (26 loc) · 724 Bytes
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
function makeGrid() {
// rows, columns, table
var rows = $('#input_height').val();
var columns = $('#input_width').val();
var table = $('#pixel_canvas');
table.children().remove();
//create rows and columns
for (var i=0; i<rows; i++) {
table.append('<tr></tr>');
for (var j=0; j<columns; j++) {
table.children().last().append('<td></td>');
}
}
//select color to the table
table.on('click', 'td', function() {
var color = $('#colorSelector').val();
$(this).attr('bgcolor', color);
});
}
$('#submit').on('click', function(event) {
event.preventDefault();
makeGrid();
});
$('#submit').click('clear', function(event) {
event.preventDefault();
});