如何使用js从页面中删除随机数

我有一张桌子:

 <table class="border" id="myTable">
      <tr>
        <th colspan="2">1</th>
        <th><a href="https://www.w3schools.com/css/css_quiz.asp" ><img class="img" src="cell.jpg"></a></th>
        <th>3</th>
        <th><a href="https://www.testdome.com/tests/html-css-online-test/13"><img class="img" src="cell.jpg"></a></th>
      </tr>
      <tr>
        <th>5</th>
        <th>6</th>
        <th>7</th>
        <th>8</th>
        <th>9</th>
      </tr>
      <tr>
        <th>10</th>
        <th>11</th>
        <th>12</th>
        <th>13</th>
        <th>14</th>
      </tr>
      <tr>
        <th>15</th>
        <th>16</th>
        <th>17</th>
        <th>18</th>
        <th>19</th>
      </tr>

    </table>  

我需要添加一个按钮DELETE,单击它应该从页面中删除一个随机数。

 let targets = document.getElementsByTagName('th');
            let butDelete = document.createElement('button');
            butDelete.innerHTML = 'Delete th';
            document.body.appendChild(butDelete);
            butDelete.addEventListener('click', function(){
              for (i = 0; i < targets.length; i++) {
                 rand = Math.floor(Math.random() * targets.length);
                 targets[rand].style.display = 'none';
              }
            });

但是它删除了几分,每次单击只需要1分。

评论