Imagine a square box displayed as a "div" element. When you click on it, it splits into an n x n grid with each square having a random background color. However, the issue I am encountering is that I want to apply additional CSS to each of these randomly created squares after clicking. Currently, the CSS is only being applied to the first square inside the grid. I have deliberately used the "next" property in my code to illustrate this specific problem. I hope this clarifies my question. Thank you in advance for your help.
Link to my code: https://drive.google.com/file/d/0B8vz7Fs9vsK2MXUxeDlLR3hyVVU/view?usp=sharing