Cell clips



  • I have nine cells and two texts. I need one of these two texts with a probability of 50 per cent. Like other cells. I hope you can help me.

    <html>
     <head>
        <meta charset="UTF-8">
        <title>Page</title>
        <script src="game.js"></script>
        <link rel="stylesheet" href="style.css">
     </head>
     <body>
     <table border="1" cellpadding="20px;">
      <tr>
       <td id="c1"><span>Cell 1</span></td>
       <td id="c2"><span>Cell 2</span></td>
       <td id="c3"><span>Cell 3</span></td>
       <td id="c4"><span>Cell 4</span></td>
      </tr>
     </table>
     </body>
    



  • That's what you can do for the 1st cell:

    var text1 = "qwe", text2 = "asd";
    $("#c1").click(function () {
        var text = Math.random() < 0.5 ? text1 : text2;
        $(this).html(text);
    });
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2