admin管理员组文章数量:1022982
I'm really lost on this concept. I've read up on the DOM and the definitions of nodes but I still don't really get it in a practical sense. For instance,
<div>
<p></p>
</div>
Would <div>
be the parent and <p>
be the child?
I'm really lost on this concept. I've read up on the DOM and the definitions of nodes but I still don't really get it in a practical sense. For instance,
<div>
<p></p>
</div>
Would <div>
be the parent and <p>
be the child?
-
2
<p>
is the child. Think of it like which ever is nested is the child and the one above it is its parent. – Vladimir Bogomolov Commented Apr 5, 2019 at 6:49 - Thanks, do you have a link to some document where I could read more about that? I tried MDN and w3c but am having trouble finding relevant information – Marcus Commented Apr 5, 2019 at 6:51
- 3 Take a look at this: w3/TR/WD-DOM/introduction.html – Donny Commented Apr 5, 2019 at 6:53
3 Answers
Reset to default 4Exactly, in your code <div>
would be the parent and <p>
the child.
Here is a piece of code
<html>
<title>example</title>
<body>
<head>
<div> </div>
</head>
</body>
</html>
In the code above <div>
is the child of <head>
, <head>
child of <body>
and <body>
child of <html>
. Starting from <html>
parent of <body>
, <body>
parent of <head>
and so on.
Yes, <div>
is the parent and <p>
is the child
To understand it a bit more let's add another <p>
<div>
<p id='first-paragraph'></p>
<p id='second-paragraph'></p>
</div>
Now <p id='first-paragraph'>
and <p id='second-paragraph'>
are both children of <div>
And one more fact is that they are siblings, since they are on the same level sharing the same parent (<div>
)
the html structure is same like tree structure first is root that is html and elements under direct is its child and this goes on nested with elements add under this order the image may give u clear picture
I'm really lost on this concept. I've read up on the DOM and the definitions of nodes but I still don't really get it in a practical sense. For instance,
<div>
<p></p>
</div>
Would <div>
be the parent and <p>
be the child?
I'm really lost on this concept. I've read up on the DOM and the definitions of nodes but I still don't really get it in a practical sense. For instance,
<div>
<p></p>
</div>
Would <div>
be the parent and <p>
be the child?
-
2
<p>
is the child. Think of it like which ever is nested is the child and the one above it is its parent. – Vladimir Bogomolov Commented Apr 5, 2019 at 6:49 - Thanks, do you have a link to some document where I could read more about that? I tried MDN and w3c but am having trouble finding relevant information – Marcus Commented Apr 5, 2019 at 6:51
- 3 Take a look at this: w3/TR/WD-DOM/introduction.html – Donny Commented Apr 5, 2019 at 6:53
3 Answers
Reset to default 4Exactly, in your code <div>
would be the parent and <p>
the child.
Here is a piece of code
<html>
<title>example</title>
<body>
<head>
<div> </div>
</head>
</body>
</html>
In the code above <div>
is the child of <head>
, <head>
child of <body>
and <body>
child of <html>
. Starting from <html>
parent of <body>
, <body>
parent of <head>
and so on.
Yes, <div>
is the parent and <p>
is the child
To understand it a bit more let's add another <p>
<div>
<p id='first-paragraph'></p>
<p id='second-paragraph'></p>
</div>
Now <p id='first-paragraph'>
and <p id='second-paragraph'>
are both children of <div>
And one more fact is that they are siblings, since they are on the same level sharing the same parent (<div>
)
the html structure is same like tree structure first is root that is html and elements under direct is its child and this goes on nested with elements add under this order the image may give u clear picture
本文标签: javascriptWhat are parent and child nodes in practical use in htmlStack Overflow
版权声明:本文标题:javascript - What are parent and child nodes in practical use in html? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745551528a2155653.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论