I know this is an old and answered question and I'm not looking for votes I just want to add an extra little thing that I think might help newcomers.
yes appendChild
is a DOM
method and append
is JQuery method but practically the key difference is that appendChild
takes a node as a parameter by that I mean if you want to add an empty paragraph to the DOM you need to create that p
element first
var p = document.createElement('p')
then you can add it to the DOM whereas JQuery append
creates that node for you and adds it to the DOM right away whether it's a text element or an html element
or a combination!
$('p').append('<span> I have been appended </span>');