Getting the height of a div

前端 未结 4 376
别跟我提以往
别跟我提以往 2021-01-03 07:30
test | test | test
相关标签:
4条回答
  • 2021-01-03 07:45

    $("#learning_menu").height() will return the span's height

    0 讨论(0)
  • 2021-01-03 07:48

    Hm. I am not sure wither I’ve got your issue right or not but… From pure javascript you can use clientHeight (or offsetHeight) property of the element to get it’s height in pixels. From jquery just use .height() method (wich is actually a browser-agnostic wrapper around clientHeight property).

    0 讨论(0)
  • 2021-01-03 07:52

    Using jQuery: that would be the .height() method.

    var span_height = $('#learning_menu').height(),
        div_height = $('#aLM').height();
    

    N.B. it is invalid HTML to place a block-level element (in this case the <div>) inside of an inline element (the <span>).

    0 讨论(0)
  • 2021-01-03 07:54

    Here it is in plain js and no jQuery required:

    document.getElementById("learning_menu").offsetHeight;
    
    0 讨论(0)
提交回复
热议问题