I have this javascript function to trigger with the body onload function, but I cannot get it to work. What am I doing wrong here? Here is my fiddle and code below:
HTML:
<body onload="loading()">
<div id="container">
</div>
</body>
JS:
function loading(){
document.getElementById('container').css("background-image", "none");
}
also tried
function loading(){
document.getElementById('container').cssText = "background-image: none";
}
CSS:
body{
background: #000;
}
#container {
width: 600px;
height: 500px;
margin:0 auto;
background-image: url("http://lamininbeauty.co.za/images/gallery/loading.png");
background-repeat: no-repeat;
background-position: 50% 50%;
}
getElementByIdreturns an html element which has no method.css(). Its jQuery that has that method, also you have your function in onload so its wrapped in a function, you want it in no wrap head.http://jsfiddle.net/3pDsJ/35/