Web Developers and programmers code snippets

jQuery Check if image exists

There is a quick way to do this without using AJAX to check for a 404.

var image = $('<img src="/images/myimage.png" />'); if (image.attr('width') > 0) imageExists = true; else imageExists = false;

Most Recent

Most Viewed