Image preview JavaScript with mouseover -


i trying use mouseover event on thumbnail images show larger image above. have 3 images class 'preview', , writing function update(), takes parameter previewpic, in external js file want change background-image of seperate div thumbnail preview. 'x' div want set background image to, 'y' believe going wrong. code follows:

function update(previewpic){     x = document.getelementbyid('image');    y = previewpic.getattribute('src');    x.style.backgroundimage = url('y'); } 

you need change way you're assigning variable/string

x.style.backgroundimage = 'url(' + y + ')'; 

Comments