Skip to content

jquery#after "Inserting Disconnected DOM nodes" example doesn't work #559

@bradvogel

Description

@bradvogel

The following example in http://api.jquery.com/after/#disconnected-dom-nodes:

$( "<div></div>" )
  .after( "<p></p>" )
  .addClass( "foo" )
  .filter( "p" )
    .attr( "id", "bar" )
    .html( "hello" )
  .end()
  .appendTo( "body" );

claims that the following should have been added to the body:

<div class="foo"></div>
<p class="foo" id="bar">hello</p>

using jQuery > 1.4. However, trying this example in jQuery 1.9.1 (on the jQuery documentation page itself), only the <div> gets added to the body:

<div class="foo"></div>

Therefore, the example appears to be incorrect or there's a bug in the framework.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions