Side navigation
#13684 closed bug (notabug)
Opened March 27, 2013 08:34PM UTC
Closed March 28, 2013 01:06AM UTC
Create element, wrap it, append to it
Reported by: | idiotbarn@hotmail.com | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Hi
I stumbled upon this, and thought you might wanted to know... I create an element with jquery. Then I wrap it around an existing DOM element. When trying to append to the created element, it fails unless if I research the DOM
<html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> </head> <body> <div id="ss"></div> <script> $(document).ready(function () { var elem = $("<div id='wrapper'></div>"); $("#ss").wrap(elem); //elem.append($("<div class='child'></div>")); //do not work //$(elem).append($("<div class='child'></div>")); //do not work //$("#wrapper").append($("<div class='child'></div>")); //works }); </script> </body> </html>
Attachments (0)
Change History (1)
Changed March 28, 2013 01:06AM UTC by comment:1
resolution: | → notabug |
---|---|
status: | new → closed |
See last example on docs:
"Notice it doesn't move the object but just clones it to wrap around its target."
http://api.jquery.com/wrap/
This is a correct behavior. A test case showing those are different elements: http://jsfiddle.net/m_gol/j5Qpt/