Synchronization problem in my multiplayer card game [closed]

I have a single/multi player card game. I have a synchronisation problem in multiplayer. When I click on cards nothing changes in player 2 and player 1 and player 2 don’t have the same card table.

For example player 1 has a fox on card 1 and player 2 has a lion on card 1. Separately I want player 1 to click on 2 cards and after matching I want player 2 to take his turn but I couldn’t do that either, can you help me, thanks.

1. Player Screen
2. Player Screen

I wrote a code that asks us to enter the room name when Multiplayer is clicked so that I can gather 2 players in a room. When both players enter the room, the card table screen comes up in 3.5 seconds and the game starts, but as I said, I couldn’t synchronize. I tried to give socket.id to both users because the cardOpened information in this code I wrote came to the 2nd player, not the 1st player. I tried to give socket.id to both users, I fixed it, but now nothing appears on the 2nd player.

socket.on('cardOpened', (data) => {
  var id = data.id;
  var img = data.img;

  $("#" + id + " img").attr("src", img);
  $("#" + id + " img").slideDown("fast");

  if (ImgOpened != "") {
      CheckMatch(id);
  }
});