Hi everyone
Attached is my code where I want background image of a div to be selected by js:
<!DOCTYPE html>
<html lang = "en">
<head>
<title>to-forum.html</title>
<meta charset="utf-8" />
<style>
.logo
{
width:1200px;
height:300px;
margin:auto;
display: block;
background-repeat:no-repeat;
position:relative;
border-radius: 25px;
}
</style>
<script>
function ChangeImage(param)
{
switch(param)
{
case '1':
return("images/greensilver.gif");
break;
case'2':
return("images/greensilver1.gif");
break;
}
}
</script>
</head>
<body>
<div id="logo">
<script>
document.getElementByClassName("logo").style.backgroundImage = "url('" + ChangeImage('1') + "')";
</script>
</div>
</body>
</html>
The image dont show ! Can you help me the code?