代码之家  ›  专栏  ›  技术社区  ›  Yagami Light

从表号获取密码验证

  •  0
  • Yagami Light  · 技术社区  · 6 年前

    这就是我想做的:

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  0
  •   brk    6 年前

    把所有的 td td公司 &附加(amp;A) td公司 input

    [...document.querySelectorAll("#passwordTable td")].forEach(function(item) {
      item.addEventListener('click', function() {
        document.getElementById('pass').value += item.textContent.trim();
    
      })
    
    })
    td {
      cursor: pointer
    }
    
    td:hover {
      background: blue;
      zoom: 1.1;
      color: #fff;
    }
    <input type='password' id='pass'>
    <table border="2" id="passwordTable">
      <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
      </tr>
      <tr>
        <td>4</td>
        <td>5</td>
        <td>6</td>
      </tr>
      <tr>
        <td>7</td>
        <td>8</td>
        <td>9</td>
      </tr>
    </table>