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
views:
35answers:
3
+2
A:
Wait, so why doesn't this work?
$("body").append('<div id="your_div" />');
tjko
2010-07-28 15:29:22
didn't know the body was an attribute. =)
DerNalia
2010-07-28 15:31:30
@DerNalia `body` is a `tag` and not an attribute... :)
Reigel
2010-07-28 15:38:04
@DerNalia `body` is not an attribute. In jQuery, it is a `selector`
Ninja Dude
2010-07-28 15:38:26
Both correct. @DerNalia, you can use HTML tags, CSS selectors, and more as selectors in jQuery. Find out more on the doc pages of the selector engine jQuery uses, Sizzle (http://wiki.github.com/jeresig/sizzle/).
tjko
2010-07-28 15:59:53
A:
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/
s3m3n
2010-07-28 15:42:01