Deprecated: Typecho\Widget\Request::getServer(): Implicitly marking parameter $default as nullable is deprecated, the explicit nullable type must be used instead in D:\PHP_HOME\www\gp_blog\var\Typecho\Widget\Request.php on line 219

Deprecated: Typecho\Request::getServer(): Implicitly marking parameter $default as nullable is deprecated, the explicit nullable type must be used instead in D:\PHP_HOME\www\gp_blog\var\Typecho\Request.php on line 349

Deprecated: Typecho\Widget\Response::goBack(): Implicitly marking parameter $suffix as nullable is deprecated, the explicit nullable type must be used instead in D:\PHP_HOME\www\gp_blog\var\Typecho\Widget\Response.php on line 158

Deprecated: Typecho\Widget\Response::goBack(): Implicitly marking parameter $default as nullable is deprecated, the explicit nullable type must be used instead in D:\PHP_HOME\www\gp_blog\var\Typecho\Widget\Response.php on line 158
jquery 判断 图片链接是否有效 src - 开发者

判断图片的src,如果不是有效的图片路径,隐藏

$(document).ready(function(){
    $(".imglst > img").each(function(){
        var id=$(this).attr('id').replace("img_","li_");
        var img=new Image();
        img.src=$(this).attr('src');
        img.onload=function(){
            if(img.width>0 || img.height>0)
            {}
            else
            {
                $("."+id).css("display","none");
            }
        }
        img.onerror=function(){
            $("."+id).css("display","none");
        }
    });
});

标签: none

评论已关闭