把所有的
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>