码迷,mamicode.com
首页 > Web开发 > 详细

js 的 一些操作。。。

时间:2017-06-23 18:22:57      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:cti   load   this   tin   图片   span   div   操作   blog   

// 对错误图片进行处理
    $("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 的 一些操作。。。

标签:cti   load   this   tin   图片   span   div   操作   blog   

原文地址:http://www.cnblogs.com/whm-blog/p/7070889.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!