我很好奇,为什么要通过在onclick函数中直接插入id,比如调用table呢?
function See(table){
console.log(table); // how system catch automatic the element?
}
<table id='iamtable' border="1">
<thead>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th></th>
</thead>
<tbody>
<tr>
<td>Value</td>
<td>Value</td>
<td>Value</td>
<td><button onclick='See(iamtable);'>press me</button>
</tr>
</tbody>
</table>
最佳答案
为元素设置 id,在 window 对象中创建引用。你可以使用
window.theid // or short theid
而不是
document.getElementById('theid')
虽然不推荐这样做
关于javascript - 内联函数通过 id 调用自动元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67211561/