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
  • 16,287
  • 34
  • 113
  • 221

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
  • 7,066
  • 5
  • 39
  • 43