I'm using the picture
element with source
's to choose which image to load. And while I can add a load
listener, I cannot figure out which image was loaded as the img
tag's src
attribute and property are both empty, even when loaded!
<picture>
<source srcset="images/test1.png" media="(min-width: 64em)">
<source srcset="images/test2.png" media="(max-width: 63.99em)">
<!-- This will alert an empty string "" -->
<img srcset="images/test.png" alt="" onload="alert( this.src );">
</picture>
How do I determine which image was loaded?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…