js
var identbutton = document.getElementById('imagebutton');
var imag = document.getElementById('contentimage');
var runtext = function(){
imag.style.background="url(../images/contimgtwo.jpg)";
}
identbutton.addEventListener("click",runtext,"false");
html
<button id="imagebutton">click here to change images</button>
<img id="contentimage"></a>
css
#contentimage {
display:block;
background:url(../images/contimg.jpg);
top:1600px;
width:500px;
height:400px;
position:absolute;
}
#contentimage:hover {
opacity:0.5;
cursor:crosshair;
}
I'm trying to make the image change when i press the button and so when you press the button the style of the image is suppose to change the image. This works and you can see the image change except all you see is a thin black border around the outline of the image and white space in the middle so you can't see the image. Also tried .className method instead of .style and didn't work