jQuery - Appending a div to body, the body is the object? jQuery - Appending a div to body, the body is the object? jquery jquery

jQuery - Appending a div to body, the body is the object?


jQuery methods returns the set they were applied on.

Use .appendTo:

var $div = $('<div />').appendTo('body');$div.attr('id', 'holdy');


    $('body').append($('<div/>', {        id: 'holdy'     }));


$('</div>').attr('id', 'holdy').appendTo('body');