Skip to main content

Bug Tracker

Side navigation

#990 closed bug (invalid)

Opened February 22, 2007 03:18PM UTC

Closed February 22, 2007 09:47PM UTC

Last modified June 19, 2007 09:52AM UTC

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.

Attachments (0)
Change History (2)

Changed February 22, 2007 05:26PM UTC by aercolino comment:1

This works as expected:

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

Changed February 22, 2007 09:47PM UTC by john comment:2

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.