0

I met now a strange behaviour (or normal and I didn't know about this?) in jQuery for the following code:

$("<p><div>item1</div></p>")

and the result is:

[<p>​</p>​, <div>​item1​</div>​, <p>​</p>​]

Why last <p></p> is added and where come from ?

Snake Eyes
  • 15,519
  • 32
  • 105
  • 203

1 Answers1

2

<p><div></div></p> is not valid HTML and the browser is well within its rights to attempt to correct it by closing the <p> before the <div>

The Demz
  • 6,796
  • 5
  • 36
  • 42