I wrote a short code for a simplified HTML table, which contains a section for the first and lastname. In the last section is an automatically created link, which refers to a facebook account.
I want to retrieve the HTTP status code of these links, check if it is 404 and if it is, replace the checkmark with a red cross.
Currently I tried analyzing other pages JQuery code (like those for download websites), without success. I also did some research, but most of the content refers to already loaded elements such as pictures.
How can I replace the haken.gif
with a cross.png
, if http://facebook.com/Jill-Smith/
has a 404 error in its header?
I would appreciate your help for this example, since I'm a Javascript beginner and want to learn from your answers.
tr {
background:yellow;
}
<html>
<head></head>
<body>
<table class="example">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>URL available</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td><a href="http://example.com/Jill-Smith/"><img src="http://www.gerso-shop.de/templates/8w_sunrise/img/haken.gif"/></a></td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td><a href="http://example.com/Eve-Jackson/"><img src="http://www.gerso-shop.de/templates/8w_sunrise/img/haken.gif"/></a></td>
</tr>
</table>
</body>
</html>