I'm looking for a way to display a scanned receipt image when hovering over a link within a table. I've written some code but it's not working as expected. Can anyone help me figure out what's wrong?
Here is the current state of my code:
CODE
jQuery(document).ready(function() {
$(".preview").hover(function() {
$(this).closest('img').show();
}, function() {
$(this).closest('img').hide();
});
});
.hide-image {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<tr>
<td>01/14/16</td>
<td>
<a href="#" class="preview">Lowes Receipt
<img src="image-path/image.jpg" class="hide-image" style="z-index: 100; position: absolute;" /></a>
</td>
<td>$1235.96</td>
</tr>