在JavaScript中访问div的高度 [英] Accessing the height of div in javascript

查看:63
本文介绍了在JavaScript中访问div的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div:

css

    div { width: 200px; height:auto }

标记

   <div contenteditable="true"> Text is editable </div>

现在我该怎么办才能在javascript中访问上述div的height ( numeric value )?我尝试过

Now what should i do to access the height ( numeric value ) of the above div in javascript ? I tried

$('div').height()& $('div').css("height");都返回auto.

$('div').height() & $('div').css("height"); both returns auto.

推荐答案

您可能想尝试 .innerHeight() .outerHeight() ,具体取决于您想要的内容.

You may want to try .innerHeight() or .outerHeight(), depending on what you want.

这篇关于在JavaScript中访问div的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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