Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $("#button_start_single").click(function() {
  2.     $("#game").show();
  3.     $("#menu").hide();
  4. });
  5.  
  6. $("#button_about").click(function() {
  7.     $("#about").show();
  8.     $("#menu").hide();
  9. });
  10.  
  11. $(".button_back").click(function() {
  12.     $("#menu").show();
  13.     $("#game").hide();
  14.     $("#about").hide();
  15. });
  16.  
  17. let width = 10;
  18. let height = 10;
  19.  
  20. function createTable(name) {
  21.     $("#game").append("<table id='field-" + name + "'></table>");
  22.     for (let i = 0; i < height; i++) {
  23.         $("#field-" + name).append("<tr id='row" + i + "'></tr>");
  24.         for (let j = 0; j < width; j++) {
  25.             $("#field-" + name + " #row" + i).append("<td id='data" + j + "'></td>");
  26.             $("#field-" + name + " #row" + i + " #data" + j)
  27.                 .append(`<button data-i="${i}" data-j="${j}" class="field-button"></button>`);
  28.         }
  29.     }
  30.     // $(".field-button").each(function () {
  31.     //     let button = $(this);
  32.     //     button.on("contextmenu", handleClick);
  33.     //     button.on("click", handleClick);
  34.     // });
  35. }
  36.  
  37. createTable("player1");
  38. createTable("player2");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement