I want to fade in a CSS page background image with jQuery when my page loads. I know it is possible to set a CSS page background image with jQuery and it is also possible to fade in text when a page loads but I am not sure how to do both.
You can set a CSS background image in jQuery by doing:
showBackground($("body").css({"background-image":"url(yourimage.jpg)"}));
You can fade in text by doing:
$(document).ready(function(){
$('#fade').hide();
$('#fade').append('This text should fade in.');
$('#fade').fadeIn();
});
You can load the body background image on page load but to fade it you need to use some other manipulation like putting a
divwith 100% height-width to hold background image. I have tried following and it fades in both text and background (in div).fewer style elements may also work but I have not tested.