I would like to know if anyone can explain me how the jQuery .add() is suppouse to work as I am reading in the jQuery page and trying to understand it and makes no sense to me, I do not understand the utility of it. Lets say I want to add html to all my divs, putting this
$('div').append('<p id="new">new paragraph</p>');
makes the job but putting
$('div').add('<p id="new">new paragraph</p>');
does not. In the jQuery page http://api.jquery.com/add/ we can read;
Although the new paragraph has been created and its background color changed, it still does >not appear on the page. To place it on the page, we could add one of the insertion methods to >the chain.
I do not understand why then using add instead of append or another working method.
Thanks for the time and help.
EDIT
$('div#dest').add('p.foo').append('<p id="new">PeNAROL</p>');
made me get it, thanks devundef and JamWaffles
add()doesn’t modify the DOM, it is used to combine 2 matched queries:append()is used to append elements into the DOM.