Geeks With Blogs
hmloo's World of .NET

Sometimes when the image isn't available on server, the web page will show a broken image. so we can display a "no image available" image for good user experience. I will implement it using Jquery.

$(document).ready(function()
{
    $("img").error(function()
    {
        $(this).hide();
    })
    .attr("src", "noimage.jpg");
});

Please note that we must first hide the broken image, or else even if we set the src to noimage, it still can not show  noimage icon.

Posted on Tuesday, March 20, 2012 7:23 PM | Back to top


Comments on this post: Replace broken image with noimage icon using Jquery

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © hmloo | Powered by: GeeksWithBlogs.net | Join free