js 的 一些操作。。。

Posted 正义的伙伴!

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 来将 字符串 转为数字。。。。。。。

以上是关于js 的 一些操作。。。的主要内容,如果未能解决你的问题,请参考以下文章