KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Using php to get 100 photos url from a db and show them on a page, but some photos may no longer exist. If the photo url is fail (404) I want to use jquery to hide the image and don't want to show any error picture. This is my code but it doesn't work. html <div id=test> <img src="http://test.com/test1.jpg" /> <img src=" http://test.com/test2.jpg" /> <img src="http://test.com/test3.jpg" /> </div> jquery var pic_list = jQuery("#test img"); pic_list.load(function () { var http = new XMLHttpRequest(); http.open('HEAD', pic_list, false); http.send(); if (http.status == 404) { pic_list.hide(); } else { pic_list.show(); } });
Tags (comma-separated)
Save Edits
Cancel