Skip to main content

Bug Tracker

Side navigation

#12982 closed bug (notabug)

Opened November 28, 2012 07:20PM UTC

Closed November 28, 2012 07:29PM UTC

Last modified February 17, 2013 02:50PM UTC

previousSibling and nextSibling are null after using the .after method to insert an element

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:

When I use .after() to insert an item into the DOM tree, the item is inserted but the nextSibling of the item I am inserting after isn't set and the previousSibling of the item I am inserting is also left as null. Sample code:




function () {


test("after", function () {

var $html = $("<input type='text'/>");

var $datePicker = $('<button class="calendar"></button>');


var nextItem = $;

var prevItem = $datePicker.prev();

equal(nextItem.length, 1, "Correct next item");

equal(prevItem.length, 1, "Correct prev item");




When run in qunit this fails. It worked in 1.7.2.

Attachments (0)
Change History (2)

Changed November 28, 2012 07:29PM UTC by dmethvin comment:1

resolution: → notabug
status: newclosed

There have been several bugs in the implementation of .before() and .after() with detached elements over several versions. After looking at the semantics we decided that it was trying to serve too many use cases. As of 1.9, they don't work on detached elements at all. More information will be coming in the 1.9 upgrade guide.

Changed February 17, 2013 02:50PM UTC by gibson042 comment:2

#13462 is a duplicate of this ticket.