Jump to content

How get parent node?


sajan

Recommended Posts

object.parentNode.getAttribute("id") should work fine.However, if the parent node doesn't have an ID this isn't going to be much use. If you want to just get the parent node alone just use object.parentNode.

Link to comment
Share on other sites

Because all you're doing is telling the variable "childnode" to be a string that says "testChild".The variable [childNode] is reserved anyways.What you're supposed to do is this://Write the following code as it is into your document.var obj = document.getElementById("testChild");alert(obj.parentNode.getAttribute("id"));

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...