Javascript 使用javascript获取div的偏移高度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3990078/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 07:02:33  来源:igfitidea点击:

Getting the offset height of a div using javascript

javascriptjquery

提问by Chris

Possible Duplicate:
Accessing the height of div in javascript

可能的重复:
在 javascript 中访问 div 的高度

We're trying to alter msdropdownto "drop up" if the menu will go off the frame. In order to figure if that's going to happen we need to check the location of the drop down box relative to the frame that it's in. From there it's easy make the thing open upwards, but the location is troubling us. Getting the element by id doesn't seem to reach through the several frames to the one we're using. Is there an easy way to do this?

如果菜单脱离框架,我们正在尝试将msdropdown更改为“下拉”。为了确定这是否会发生,我们需要检查下拉框相对于它所在框架的位置。从那里很容易让东西向上打开,但位置让我们感到不安。通过 id 获取元素似乎无法通过几帧到达我们正在使用的帧。是否有捷径可寻?

采纳答案by Mayur

JQuery offset might help you in getting relative position of dropdown.

JQuery 偏移量可能会帮助您获取下拉列表的相对位置。

Read more about it

阅读更多相关信息