function eating(Num) {
console.log("entered eating", Num);
bodyEating = Num;
for (let i = 0; i < Num; i++) {
BODYEATING[0].background = "black";
}
console.log(BODYEATING[0]);
//e.preventDefault();
}
<div class="container text-center">
<img src="https://media.geeksforgeeks.org/wp-content/uploads/unique-rectangles-formed-using-n-unit-squares.png" usemap="#image-map">
<map id="map" name="image-map">
<area target="_self" alt="1" title="1" onclick="eating(1)" coords="21,385,24,309,100,309,101,385" shape="poly">
<area target="_self" alt="2" title="2" onclick="eating(2)" coords="102,305,23,304,23,228,101,227" shape="poly">
<area target="_self" alt="3" title="3" onclick="eating(3)" coords="103,225,26,228,25,149,99,151" shape="poly">
<area target="_self" alt="4" title="4" onclick="eating(4)" coords="103,147,102,65,25,70,23,147" shape="poly">
</map>
</div>
I have something like 5 images, each image is a pile of 10 squares. I want for each image when the user clicks, for example, the image on square 3, then, I will get in my code that the user clicked on square 3 and, also, the squares from 1 to 3 will have a background-color applied.
I did the first goal by making an image map. However, I can't make the coloring goal and I've searched a lot for it. Can anyone help?