直接上马
$('img').each(function(k,i) {
if($('img').eq(k).height()<200){
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
this.src = '/Public/Main/images/no-image.jpg';
}
}else{
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
this.src = '/Public/Main/images/error-image.jpg';
}
}
});直接放在相应的js文件下就Ok了
本文提供了一段JavaScript代码,用于遍历页面上的所有图片元素,并根据图片的高度设置不同的默认图片路径。当图片加载失败或尺寸不正确时,将显示特定的占位图。
7611

被折叠的 条评论
为什么被折叠?



