Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery wrap chaining [closed]

<p>hello</p>
$("p").wrap("<div class='inner'></div>").wrap("<div class='outer'></div>");

The result is <div class="inner"><div class="outer"><p>hello</p></div></div>,

Why is it so? I expected inner inside outer, not otherwise.

Here is fiddle to play with : http://jsfiddle.net/qnYDY/

like image 522
Aigars Matulis Avatar asked Dec 04 '25 14:12

Aigars Matulis


1 Answers

I think the first wrap call returns "p" itself , so when you wrap it again, the "outer" div will wrap the "p" tag and not any of its parents.

like image 135
Manoj Nama Avatar answered Dec 07 '25 23:12

Manoj Nama