why jquery .height() get a different result on chrome?

后端 未结 3 865
情深已故
情深已故 2021-01-12 13:11

This is how chrome show the width and height of the div :

\"enter

which is cor

相关标签:
3条回答
  • 2021-01-12 13:28

    Use outerHeight() to get the height with paddings. Use outerHeight(true) to get the height with paddings + margins.

    Here's a link to the documentation.

    0 讨论(0)
  • 2021-01-12 13:33

    .height() will get you the element's height, .outerHeight() will return the height including padding, margin and borders.

    0 讨论(0)
  • 2021-01-12 13:41

    That's because on DOMReady some images are not loaded completely. You should call the height on window load.

    $(window).load(function(){
        console.log($('#container-altezza-fisso').height());
    })
    

    You can also use outerHeight:

    Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements.

    console.log($('#container-altezza-fisso').outerHeight());
    
    0 讨论(0)
提交回复
热议问题