Skip to content

Instantly share code, notes, and snippets.

@johirbuet johirbuet/design.js
Created May 25, 2018

Embed
What would you like to do?
function makeGrid() {
console.log("makeGrid is running!")
// Select size input
let canvas, cell, gridHeight, gridWidth, rows;
canvas = $('#pixelCanvas');
gridHeight = $('#inputHeight').val();
gridWidth = $('#inputWidth').val();
canvas.empty();
for (x = 0; x < gridHeight; x++) {
canvas.append('<tr></tr>');
}
rows = $('tr');
for (y = 0; y < gridWidth; y++) {
rows.append('<td></td>');
}
cell = canvas.find('td');
// When td is clicked by the user, change color of td
cell.click(function() {
// Select color input
console.log("changeColor is running!");
var color;
color = $("#colorPicker").val();
$(this).attr('bgcolor', color);
});
}
// When size is submitted by the user, call makeGrid()
var submitQuery;
submitQuery = $('input[type="submit"]')
submitQuery.click(function(event) {
event.preventDefault();
makeGrid();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.