简体   繁体   中英

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) .

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"

while you have a check for the less than < , that could be the issue change to this:

if($imgh > 187)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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