Bug Tracker

Opened 15 years ago

Closed 15 years ago

Last modified 14 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:

Description

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

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 15 years ago by aercolino

This works as expected:

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

comment:2 Changed 15 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.