Bug Tracker

Opened 10 years ago

Closed 10 years ago

#13684 closed bug (notabug)

Create element, wrap it, append to it

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:


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

 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

	<div id="ss"></div>
        $(document).ready(function () {
            var elem = $("<div id='wrapper'></div>");

            //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

Change History (1)

comment:1 Changed 10 years ago by m_gol

Resolution: notabug
Status: newclosed

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/

Note: See TracTickets for help on using tickets.