Trying to find a way to implement an image rollover effect on the picture element within a responsive website.
The big question is, can we apply an image rollover to the scrset attribute in the picture tag?
An example of an img tag with a JavaScript rollover effect that works:
<img src="media/images/feature-films/tmbs/zen-zero.jpg"
onmouseover="this.src='media/images/feature-films/tmbs/zen-zero-ro.jpg'"
onmouseout="this.src='media/images/feature-films/tmbs/zen-zero.jpg'"
alt=""/>
An example of a picture element with a JavaScript rollover effect that doesn't work:
<picture>
<source srcset="media/images/feature-films/tmbs/zen-zero-large.jpg"
onmouseover="this.src='media/images/feature-films/tmbs/zen-zero-large-ro.jpg'"
onmouseout="this.src='media/images/feature-films/tmbs/zen-zero.jpg'"
media="(min-width: 880px)">
<source srcset="media/images/feature-films/tmbs/zen-zero-small.jpg" media="(max-width: 478px)">
<source srcset="media/images/feature-films/tmbs/zen-zero-medium.jpg">
<!-- fall back -->
<img srcset="media/images/feature-films/tmbs/zen-zero-medium.jpg" alt="">
</picture>
If anyone has suggestions on how to achieve a rollover effect on the picture tag using srcset, please share!
The webpage contains around 12 responsive images that require a rollover effect.