Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#990 closed bug (invalid)

Chaining doesn't always work as expected.

Reported by: dialtone Owned by:
Priority: major Milestone: 1.1.2
Component: core Version: 1.1.1
Keywords: Cc:
Blocked by: Blocking:



Only appends the div without any trace of span.

$("<div>div</div>").attr("id","test").appendTo("body"); $("#test").after($("<span>span</span>"));

This works but it's not really a good solution because it requires me to add a new id attribute.

Change History (2)

comment:1 Changed 16 years ago by aercolino

This works as expected:

$( "<div>ciao</div>" ).appendTo( "body" ).after( "<span>bello</span>" );

comment:2 Changed 16 years ago by john

Resolution: invalid
Status: newclosed

aercolino is correct - you can't insert an element before an element that isn't actually in the document yet. His solution will suit you just fine.

Note: See TracTickets for help on using tickets.