[Fixed]-Using if and else statement in javascript to display image (if image doesn't exists display other image)

1👍

img doesn’t have a length. You can test img.width.

$(document).ready(function() {
var i = $('mythumb'); // using an id <img id='mythumb'.....
if( i.width === 0 ) i.src='y';
}

Using the same image will use the right place.

👤Holger

Leave a comment