简体   繁体   English

这个jQuery代码怎么了? (图高度)

[英]What's wrong this jQuery code? (Img height)

I want this: 我要这个:

If the img height is bigger than 187px it get a padding-top attribute with individual pixel.(current img height -(minus) 187px) . 如果img高度大于187px,则获得具有单个像素的padding-top属性。(当前img高度-(减)187px)。

The code: 编码:

    $(document).ready(function() {
         $(".tabbed-area .box-wrap .box img").load(function() {
            $imgh = $(this).height();
            if($imgh < 187)
            {   
                $real = $imgh - 187;
                $(this).css("padding-top", $real);
            }
         });

        });

You are saying "img height is bigger than 187px" 您正在说“ img高度大于187px”

while you have a check for the less than < , that could be the issue change to this: 当您检查小于<时,可能是对此的问题更改:

if($imgh > 187)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM