Clarus Dignus Clarus Dignus - 6 months ago 73x
Javascript Question

Output img.currentSrc of srcset using jQuery

I need to output the current source of an image using a jQuery alert:

alert($('.someclass img').attr('currentSrc'));

...however the alert is outputting undefined.

For reference, the mark-up is as follows:

<div class="someclass">
<img srcset=", 2x">


currentSrc is a property not an attribute. Use .prop('currentSrc')

$(function() {

<script src=""></script>
<div class="someclass">
    <img srcset=",">