Hi everyone,
I'm trying to select an image for a div's background whereby JavaScript as follows:
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 400px;
height: 400px;
border: 1px solid black;
}
</style>
<script>
function ChangeImage(param)
{
switch(param)
{
case '1':
return("http://localhost/tlushim/images/greensilver.gif");
break;
case'2':
return("http://localhost/tlushim/images/greensilver1.gif");
break;
}
}
</script>
</head>
<body>
<div id="myDiv"></div>
<script>
document.getElementById("myDiv").style.backgroundImage = "url(ChangeImage('1'))";
</script>
</body>
</html>
But I dont get any background image ! Can anyone see what's wrong with my code?
Thanks