js 的 一些操作。。。

// 对错误图片进行处理
    $("img").error(function() {
        $(this).attr("src", "http://127.0.0.1:81/img/error.jpg")
    })

    //处理图片高度。。。。。
    $(".scrollable-img img").load(function(){
        var height = parseFloat($(this).css("height"))
        if(height<204){
            $(this).css("padding-top",(204-height)/2+"px")
        }
    })

    $(".portfolio-img img").load(function(){
        var height = parseFloat($(this).css("height"))
        if(height<157){
            $(this).css("padding-top",(157-height)/2+"px")
        }
    })

使用 parsetInt 或者 parseFloat 来将 字符串 转为数字。。。。。。。

posted on 2017-06-23 17:11  正义的伙伴!  阅读(132)  评论(0编辑  收藏  举报

导航

//增加一段JS脚本,为目录生成使用