Alex Rivera | Logout

jQuery: how do I add a div to the end of my HTML file?

Asked 2010-07-28T15:27:13.157
15

I saw in the documentation that .append allows you to add things to an element. But I want to end a div right before the </body> tag

Edit
Report

1 Answer

27

You can use this:

$('body').append('<div>footer</div>');

but also this:

$('<div>footer</div>').appendTo('body');

or this:

$('body').html($('body').html()+'<div>footer</div>');

Reference with differences here: http://api.jquery.com/appendTo/

answered 2010-07-28T15:42:01.990

Your Answer