Skip to content

Commit

Permalink
onclick
Browse files Browse the repository at this point in the history
  • Loading branch information
muktar1907 committed Apr 24, 2024
1 parent 806ecf9 commit 59feb57
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,23 @@ <h1>The Word Search Game</h1>
document.body.appendChild(tbl);
tbl.setAttribute("border","1.5");
}

function buttonClick(cell,action)
var cells = document.querySelectorAll("td");
for(var i=0;i<cells.length;i++)
{
cells[i].addEventListener("click",buttonEvent(cells[i].getAttribute("id"),0));
cells[i].addEventListener("mouseover",buttonEvent(cells[i].getAttribute("id"),1));
}
function buttonEvent(cell,action)
{
const button= document.getElementById(cell.toString());
button.style.backgroundColor="blue";
U = new UserEvent();
U.cell=cell;
U.action=action;
U.player=player;
U.gameId=gameId;

socket.send(JSON.stringify(U));
//socket.send(JSON.stringify(U));
console.log(JSON.stringify(U));
}
</script>
Expand Down

0 comments on commit 59feb57

Please sign in to comment.