Jump to content

How get parent node?


sajan
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...