I'm trying to use onerror with source tag but the function isn't being called.
<picture>
<source srcset="<?=home(1).str_replace(array('.jpg', '.png', '.gif'),".webp",$movie->thumb3) ?>" type="image/webp" onerror="fallback()">
<source srcset="<?=home().$movie->thumb3 ?>" type="image/jpeg">
<img src="<?=home().$movie->thumb3 ?>" alt="<?=$movie_title?>">
</picture>
javascript
function fallback() {
var src = $(this).attr("srcset");
src = src.replace("https://webp","https://images");
$(this).attr("srcset",src);
}
The fallback image isn't being used? How do i solve?