search

Home  >  Q&A  >  body text

javascript - Why is the value obtained using jq's outerHeight() inaccurate?


##As shown in the picture, shouldn’t I get 55.17?

淡淡烟草味淡淡烟草味2869 days ago683

reply all(4)I'll reply

  • 滿天的星座

    滿天的星座2017-05-18 10:59:02

    $('.pr-tab').get(0).getBoundingClientRect().height gets the real data
    For details, please refer to http://stackoverflow.com/ques...

    reply
    0
  • PHPz

    PHPz2017-05-18 10:59:02

    Returns the value represented by an integer (excluding "px"), or null if the method is called on an empty collection.

    The document says that the outerHeight() method can only return an integer value. Your 55.17 was rounded off and only returned 55

    reply
    0
  • ringa_lee

    ringa_lee2017-05-18 10:59:02

    I usually use element.offsetHeight; && element.offsetWidth in native JS. Reference link https://developer.mozilla.org...

    reply
    0
  • PHPz

    PHPz2017-05-18 10:59:02

    Give a delay. You have started calculating the height before the dom is inserted. Give a delay of 50
    ms before getting the value

    reply
    0
  • Cancelreply