Using same onmouseover function for multiple objects
- by phpscriptcoder
I'm creating a building game in JavaScript and PHP that involves a grid. Each square in the grid is a div, with an own onmouseover and onmousedown function:
for(x=0; x < width; x++)
{
for(y=0; y < height; y++)
{
var div = document.createElement("div");
//...
div.onmouseclick = function() {blockClick(x, y)}
…