I'm having trouble finding the specific functionality I need. My goal is to add sibling DOM elements to a disconnected node.
From what I gather, it should be possible with either .after() or .add(), but for some reason both methods are not working as expected:
var $set = $('<div class="parent"></div>');
$set.add('<div class="child"></div>');
$set.add('<div class="child"></div>');
$set.add('<div class="child"></div>');
$('body').append($set);
http://jsfiddle.net/kh9Uj/17/ and http://jsfiddle.net/kh9Uj/19/
When I chain the .add() method, like this:
$('<div class="parent"></div>')
.add('<div class="child"></div>')
.add('<div class="child"></div>')
.add('<div class="child"></div>')
.appendTo('body');
However, chaining does not work with .after(). Unfortunately, in my application, chaining is not an option. How can I achieve this?
Edit made to correct the class/id issue.