Bug Tracker

Modify

Ticket #990 (closed bug: invalid)

Opened 6 years ago

Last modified 6 years ago

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:
Blocking: Blocked by:

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

comment:1 Changed 6 years ago by aercolino

This works as expected:

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

comment:2 Changed 6 years ago by john

  • Status changed from new to closed
  • Resolution set to invalid

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.