Search This Blog

2016/11/09

When img failed show others|无法取得img时显示其他图片

Use onerror to show other img:
使用onerror来实现:
<img src="invaild path" onerror="script">

Ex./例:
<img src="invaild path" onerror="this.scr='right.img';">

Replace invaild img with right.img
图片不存在时,将图片替换成图片right.img

Or by jQuery/或者使用
<img src="invaild path" id="image">
<script>
$("#image").error().attr("src","right.img");
</script>

No comments :

Post a Comment