我正在使用picture
带有 's 的元素source
来选择要加载的图像。虽然我可以添加一个load
侦听器,但我无法确定加载了哪个图像,因为img
标签的src
属性和属性都是空的,即使加载时也是如此!
<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>
如何确定加载了哪个图像?