-
Notifications
You must be signed in to change notification settings - Fork 0
/
designs.js
37 lines (32 loc) · 845 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
// Select color input
// Select size input
var color,height,width ;
// When size is submitted by the user, call makeGrid()
$('#sizePicker').on('submit', function(evt){
evt.preventDefault();
height = $('#inputHeight').val();
width = $('#inputWeight').val();
makeGrid(height,width);
});
function makeGrid(x,y) {
// TODO : create the grid..
// Your code goes here!
$(document).ready(function(){
$('#pixelCanvas').empty();
for (var i = 0; i < x ;i++){
$('#pixelCanvas').append('<tr id="row'+ i+'"></tr>');
for (var j = 0; j < y ;j++){
$('#row'+i).append('<td id="cell"></td>');
}
}
//coloring the grid...
$('td').on('click', function colorPicker(){
color = $('#colorPicker').val();
if ($(this).attr('style')) {
$(this).removeAttr('style');
} else {
$(this).attr('style','background-color:'+color);
}
});
});
}