eudaimonious
12/15/2013 - 4:28 PM

Add a node with before, insertBefore, after, insertAfter, prepend, prependTo, append, appendTo.

Add a node with before, insertBefore, after, insertAfter, prepend, prependTo, append, appendTo.

// 1. Wait for DOM to load
// 2. Create the element
// 3. Append it somewhere

$(document).ready(function() {
  var price = $('<p>From $399.99</p>');
 // Append statement here
});

// Before
$('.vacation').before(price); //or
price.insertBefore($('.vacation'));
// Puts price node before .vacation node

// After
$('.vacation').after(price); //or
price.insertAfter($('.vacation'));
// Puts price node after .vacation node (and all nodes .vacation contains)

// Prepend
$('.vacation').prepend(price);//or
price.prependTo($('.vacation'));
// Puts price at the top of (and inside) the .vacation node

// Append
$('.vacation').append(price); //or
price.appendTo($('.vacation'));
// Puts the price node at the bottom of (yet inside) the .vacation node