How to make it so that when you click on any of them, the square starts to blink smoothly changing the opacity?
Here is the code:
var cols = prompt('Введите количество строк', ''); var rows = prompt('Введите количество столбцов', ''); cols = parseInt(cols); rows = parseInt(rows); document.write('<table border="1" cellpadding="2" cellspacing="0" width="1000px" height="600px">'); var color; function getColor() { var min = 1, max = 2; var colorNum = Math.round(Math.random() * (max) + min), color; if (colorNum == 1) { color = 'blue'; } if (colorNum == 2) { color = 'green'; } if (colorNum == 3) { color = 'red'; } console.log(colorNum); return color; } for (i = 1; i <= cols; i++) { for (j = 1; j <= rows; j++) { document.write('<td style="background-color:' + getColor() + '"></td>'); } document.write("</tr>"); } document.write('</table>'); table { margin: 0 auto } 