問題:
I am trying to find the closest element with a specific tag name without jquery.我試圖在沒有 jquery 的情況下找到具有特定標籤名稱的最近元素。 When I click on a <th>
I want to get access to the <tbody>
for that table.當我單擊<th>
我想訪問該表的<tbody>
。 Suggestions?建議? I read about offset but didn't really understand it too much.我讀過偏移量,但並沒有真正理解它。 Should I just use:我應該只使用:
Assume th is already set to clicked th element假設 th 已經設置爲 clicked th 元素
th.offsetParent.getElementsByTagName('tbody')[0]