图片加载失败时,如何自动切换至预设默认图片?

更新于
2026-09-29 11:05:33
0阅读来源:SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计46个文字,预计阅读时间需要1分钟。

图片加载失败时,如何自动切换至预设默认图片?

plaintext使用方法一:$(document).ready(function() { $('#img').error(function() { $(this).attr('src', 'default.jpg(默认图片的url)'); });});

gistfile1.txt

方法一、 $('img').error(function(){ $(this).attr('src', "default.jpg(默认图片的url地址)"); }); 方法二.

图片加载失败时,如何自动切换至预设默认图片?