我有一個HTML表,此表:檢索父節點的childNode使用jQuery
<html>
<table>
<thead>
<tr>
<th idth='keyth'></th>
</tr>
</thead>
<tbody>
<tr>
<td class='edit' idtd='keytd'></td>
</tr>
</tbody>
</table>
</html>
現在我想在jQuery來檢索屬性「keyth」從編輯類離開的內容。 例:
$(".edit") {
"th_id": this.parentNode.....childNode.getAttribute("idth"),
//Here I dont know how to achieve the attribute content
});
謝謝您的建議!
我終於發現只有JavaScript的解決方案:
"th_id":this.parentNode.parentNode.parentNode.childNodes[0].childNodes[0].childNodes[0].getAttribute("idth")
看一看我的回答更快。 – redV