Add dom element in html using jquery

Hello
Please can someone tell me why this does not work

$(‘<div>Hello where is my soy latte?</div>’); inorder to add a Dom element to the page

this is an eg from the book Jquery Novice to ninja
Thanks
Meera

$(‘<div>Hello where is my soy latte?</div>’).appendTo(‘body’);

You need to append it or prepend it to an element. Right now you are creating it, but not actually telling jQuery where to put it

or simply
$(‘body’).html(‘<div>Hello where is my soy latte?</div>’)

Many Thanks for your prompt answer
Meera

If you use this approach you will overwrite your existing HTML, since you specifically wanted to add to the dom, I suggest using appendTo or prependTo

just for learning purpose
and
$(sel).html(html)
is the simplest way to add html to the dom