Reputation: 369
<div><p><p></p></p></div>
<script>
alert(document.getElementsByTagName("div")[0].innerHTML);
</script>
Execute the code
I found something unusual the alert shows me 3<p>
elements. Well I have declared only two.
its actually showing one more than declared. Someone explain this.
Upvotes: 0
Views: 38
Reputation: 504
you can't have paragraphs inside paragraphs. try this:
<div><p></p><p></p></div>
<script>
alert(document.getElementsByTagName("div")[0].innerHTML);
</script>
Upvotes: 2