我试图找到没有jquery的具有特定标签名称的最接近的元素.当我点击一个<th>我想要访问<tbody>该表时.建议?我读过有关偏移的内容,但并没有真正理解它.我应该使用:
假设th已经设置为单击了元素
th.offsetParent.getElementsByTagName('tbody')[0]
Run Code Online (Sandbox Code Playgroud) 内联事件处理程序被认为是一种不好的做法吗?
例如: <button onclick=someFunction()>Click me!</button>
如果是这样,使用内联事件处理程序有什么缺点?
我在表头中有一个包含几个输入字段的tr.
有没有办法通过点击其中一个输入字段我可以得到父表的ID?
我的tr看起来像这样:
<table id="tableID">
<thead>
<tr>
<th><input type="text" name="input1" id="input1" /></th>
<th><input type="text" name="input2" id="input2" /></th>
<th><input type="text" name="input3" id="input3" /></th>
</tr>
</thead>
<tbody>
// ...
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)