I created a pixel art creator using jQuery and added functionality to re-enter the default "draw" mode after using the "erase" mode. It works to color multiple cells, but my code for coloring a single cell does not work.
If you:
- Use the fill button to fill the grid with color
- Click "erase" and delete one cell
- Click draw and try to color the erased cell.
The cell is filled with color for a second of a second, and then cleared again. However, if you simply press the drawing mode after loading the page and click on the cell, it will be colored in normal mode.
Here is the code I used (part of another function). To view my full code / see how it works, you can view CodePen .
$('td').click(function() {
const color = $('.color-picker').val();
$(this).css('background-color', color);
});
source
share