The body is part of an HTML document. It contains the content of that document.
Questions tagged [document-body]
268 questions
114
votes
8 answers
Difference between $(document.body) and $('body')
I am a jQuery beginner and while going through some code examples I found:
$(document.body) and $('body')
Is there any difference between these two?
user1617640
32
votes
4 answers
scrollTop() returns 0 in Firefox, but not in Chrome
Not sure if there's another question regarding this, if so I apologize and please don't release the hounds.
Using the html5 doctype and doing a quick console.log off my scroll listener that tells me the value of scrollTop() value. I'm basically…

lxndr
- 702
- 1
- 11
- 25
24
votes
5 answers
Find body tag in an ajax HTML response
I'm making an ajax call to fetch content and append this content like this:
$(function(){
var site = $('input').val();
$.get('file.php', { site:site }, function(data){
mas = $(data).find('a');
mas.map(function(elem, index) {
…

Youss
- 4,196
- 12
- 55
- 109
22
votes
3 answers
When do you put Javascript in body, when in head and when use doc.load?
Possible Duplicate:
Where to place Javascript in a HTML file?
Should I write script in the body or the head of the html?
I've always wondered, mainly because when creating pages I always run into trouble, based on the following thing:
When do you…

Sander Schaeffer
- 2,757
- 7
- 28
- 58
18
votes
2 answers
Browser user agent style sheet margin 8px
I was just wonerdering about a white space all around a website. I found out it is there because of the user agent style sheet (Google Chrome) and there is set a margin of 8px to the body tag as default.
How to solve this is not a problem, but I am…

Philipp Sch
- 183
- 1
- 1
- 4
13
votes
5 answers
Scroll listener on body
I would like to ask about scroll listener. I want to add scroll listener on body but it seems doesnt work.
$('body').scroll(function(){
console.log('SCROLL BODY');
});
I create basic example on fiddle, can someone explain me why it doesn't to…

user1297783
- 193
- 1
- 1
- 9
7
votes
2 answers
Random body background-image
I've tried several tutorial on the web and none seems to work properly. What I'm trying to do is quite simple I think:
I have 9 different .jpg images that I need to randomly show up on page load - to be background. This should be fairly simple…

asirgado
- 225
- 3
- 4
- 7
7
votes
3 answers
My body background color disappears when scrolling
I hope someone can help. I've set my body height property to 100% which is fine when all the content is on the screen at one time. However when i need to scroll (when minimizing the window) the body color disappears, leaving just the color i set for…

KAY DEE EMM
- 85
- 1
- 1
- 6
6
votes
3 answers
How can I disable print-screen functionality for a webpage in all browsers?
Using the following we can disable print-screens or screenshots in Internet Explorer:
But these don't work in…

ponds
- 2,017
- 4
- 16
- 11
6
votes
5 answers
Why doesn't the z-index style apply to the element?
The z-index style allows you to control what order boxes are painted in. For example, you can make a child element be painted below its parent element:
#parent {
background: rgba(33, 33, 33, 0.7);
}
#child {
width: 100px;
height: 100px;
…

Peter Olson
- 139,199
- 49
- 202
- 242
6
votes
3 answers
why do browsers style a predefined margin into all webpages?
Why do all browsers style an arbitrarily sized margin on the element of all webpages?* I'm not surprised by this, as I've been making webpages for years now, but I just assumed it was part of the spec, in the same way text inside …

Ky -
- 30,724
- 51
- 192
- 308
6
votes
2 answers
JS - set window height using current window size
I have some CSS that needs the body to have a height set, but this needs to be done depending on the user.
I have made some code that kind of works - it calculates the window height but it's not changing the body height. What am I doing…

cloggy
- 175
- 3
- 3
- 10
6
votes
3 answers
and Tags 100% Height Fail
I have an application which requires me to use CSS to set the height of the and tags to 100%, like this (JSFiddle version):
html, body {
display: block;
height: 100%;
margin: 0px;
padding: 0px;
width: 100%;
}
body {
…

Oliver Spryn
- 16,871
- 33
- 101
- 195
6
votes
5 answers
Will style css tag render in body?
I am using a CMS and apparently it has a bug that will not allow me to add any content to the of a blog post. It inserts everything into the body which in most cases that works okay but in an instance of code like this: