How do I get the height of a div's full content with jQuery?

前端 未结 6 2143
[愿得一人]
[愿得一人] 2020-11-29 02:57

I am trying to create my own scroll bars. I have tried most of the jquery scrollbar plugins and none of them seem to work for me, so I decided to create my own. I have an ov

6条回答
  •  我在风中等你
    2020-11-29 03:20

    You can get it with .outerHeight().

    Sometimes, it will return 0. For the best results, you can call it in your div's ready event.

    To be safe, you should not set the height of the div to x. You can keep its height auto to get content populated properly with the correct height.

    $('#x').ready( function(){
    // alerts the height in pixels
    alert($('#x').outerHeight());
    })
    

    You can find a detailed post here.

提交回复
热议问题