mercredi 1 avril 2015

Changing page background via Javascript

I have been trying to get this to work for the past 6 hours and I am just unable to do it right. I've looked at the questions and solutions on SO as well to no avail. What am I doing horribly wrong?!?


All I have is a html5 page with no background. In my javascript code I call upon this method when the document is ready:



/*
* Initializes the landing page.
*/
function initializeLanding(){
$('body').css({
'backround':'url("http://ift.tt/1xBMNS1")'
});
}


It should be something stupidly simple, and yet here I am. I've tried using single quotes, double quotes, without multiple attributes, etc. I would also much rather not use CSS or DOM properties to change the background, as I have set up way points along the page to change the background upon scrolling past them.


Also, if I call the .css() method and put in new attributes, will it overwrite all the old ones, or just the stated attributes in the latest css() call?


Aucun commentaire:

Enregistrer un commentaire