i need to load an background image in css after the HTML things(text box ,hyperlinks) have been loaded ...
+1
A:
Like this:
$(function() {
$('someElement').css('background', 'url("...")');
});
SLaks
2010-06-13 03:07:19
I think he means load the image "in the background", not as a background image.
inkedmn
2010-06-13 03:13:12
@inkedmn: Then he doesn't make any sense. All images are loaded in the background. (Unless he's asking to preload an image)
SLaks
2010-06-13 03:16:16
A:
In plain JavaScript:
<script type="text/javascript">
function loadBackgroundImage() {
document.body.style.backgroundImage="url(background.jpg)";
}
</script>
HTML:
<body onload="loadBackgroundImage();">
In jQuery:
<script type="text/javascript">
$(document).ready(function() {
$("body").css("background-image","url(background.jpg)");
});
</script>
Gert G
2010-06-13 03:19:02