Available: editor on jQuery

Required: so that when you select color A, the cursor while holding the key repaints the cells in color A. If you select color B in the same way, and so on.

When choosing green, draws green
switch to brown, draws green,
switch to blue draws blue
Further not to do draws in blue

Question: What is the error in my code? And how can it be optimized? Since I have vague doubts that I have done something on the verge of panic and chaos.


    1 answer 1

    What is the error in my code?

    the error is that you do not delete the installed classes, and it turns out this situation:

    <div class="ground tree water"></div> 

    water class covers all others, not sure, but probably because it comes last alphabetically

    And how can it be optimized?

    yes redo it completely! although this is my subjective opinion, but for all this, all sorts of canvas and SVG are better than the table

    • Thank. The string $ (this) .removeClass (). AddClass ("ABC"); helped. And at the expense of rewriting everything, I think as I get used to jquery and js as a whole, I will return to this issue. And this is my first working code. - Andrei Stifurak