I am trying to use JavaScript to retrieve the src or id of an image in a datalist. Below is a snippet of the code I am working with:
<script type="text/javascript">
$(document).ready(function () {
$('.productImage').mouseover(function () {
var imageUrl = $('.productImage').attr('src');
//alert(imageUrl);
$.ajax({
type: "POST",
url: "WebServiceVar.asmx/getVarImage",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "{'imageUrl':'" + imageUrl + "'}",
success: function (data) {
}
})
});
});
</script>
When hovering over any image within the datalist, only "images/products/image1.png" is displayed by the alert(imageUrl) method, despite there being multiple images in the DataList.