Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript get height.

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #45997
    nuodas159
    Participant

    Hello,
    how to get wrapper height if wrapper height: auto;? And when you get wrapper height then set on other element wrapper height.

    #141128
    Eric Gregoire
    Participant
    var h = document.getElementById('wrapperDiv').clientHeight;
    var h = document.getElementById('wrapperDiv').offsetHeight;

    clientHeight includes any vertical padding.

    offsetHeight includes any vertical padding, scrollBar, and the border.

    #141135
    nuodas159
    Participant

    how to set on element height?

    #141142
    Eric Gregoire
    Participant

    Not sure what you’re doing or what the code is that you are weaving this into, but you could set it with:

    document.getElementById('otherDiv').style.height = h; //The variable used in the previous example defining 'h' as the wrapper height.
    #141159
    nuodas159
    Participant
    #141162
    Eric Gregoire
    Participant

    Don’t you want the #block height to equal the height of the #wrapper when #block is clicked? You have it setting #block height equal to #block height which is redundant.

    #141166
    nuodas159
    Participant

    Am, yes I want to do block equal to wrapper. Can you show how to do it?

    #141209
    Eric Gregoire
    Participant

    Sorry. You can’t change clientHeight [facepalm]. Use the style object of your div. Here’s a new pen: http://codepen.io/anon/pen/sKruF

    #141254
    nuodas159
    Participant

    Thx :)

    #141270
    nuodas159
    Participant

    .. delete this post

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.