我怎样才能得到一个动态变化的div使用JavaScript的高度? [英] How can i get the height of a dynamicly varying div using javascript?

查看:65
本文介绍了我怎样才能得到一个动态变化的div使用JavaScript的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用JavaScript来获得动态div的高度?我有一个动态div,它由内容动态填充。我想知道每次div的高度。
任何人都可以帮我弄明白吗?

查看此小提琴



您可以设置/获取DIV的高度 身高



示例代码是,

  document.getElementById(demo)。style.height; 

document.getElementById(demo)。style.height =100px;

如果您在CSS中设置高度,请使用 JQuery


Is there anyway to get the height of a dynamic div using javascript?I have a dynamic div which is populated by contents dynamically.I want to know div's height each time. Can anybody help me to figure it out?

解决方案

See this Fiddle.

You can set/get the Height of DIV from height Property

Example Code is,

document.getElementById("demo").style.height;

document.getElementById("demo").style.height="100px";

If you set height in CSS means, use JQuery.

这篇关于我怎样才能得到一个动态变化的div使用JavaScript的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆