xxxxxxxxxx
<div class="container">
<div class="inner">Hello</div>
<div class="inner">Goodbye</div>
<h2>Greetings</h2>
</div>
xxxxxxxxxx
$( "p" ).add( "div" ).addClass( "widget" );
var pdiv = $( "p" ).add( "div" );
xxxxxxxxxx
$( "li" ).add( "<p id='new'>new paragraph</p>" )
.css( "background-color", "red" );
xxxxxxxxxx
$( "li" ).add( document.getElementsByTagName( "p" )[ 0 ] )
.css( "background-color", "red" );
xxxxxxxxxx
var $newdiv1 = $( "<div id='object1'></div>" ),
newdiv2 = document.createElement( "div" ),
existingdiv1 = document.getElementById( "foo" );
$( "body" ).append( $newdiv1, [ newdiv2, existingdiv1 ] );
xxxxxxxxxx
var pdiv = $( "p" );
pdiv.add( "div" ); // WRONG, pdiv will not change
xxxxxxxxxx
<h2>Greetings</h2>
<div class="container">
<div class="inner">Hello</div>
<div class="inner">Goodbye</div>
</div>
xxxxxxxxxx
<h2>Greetings</h2>
<div class="container">
<div class="inner">
Hello
<p>Test</p>
</div>
<div class="inner">
Goodbye
<p>Test</p>
</div>
</div>