jQuery 如何在Jquery中获取表格的高度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9781567/
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
How to get the height of table in Jquery
提问by John Preston
How can we get the height of the html table in jQuery. For example if we have the following code then how can we get the height of the table:-
我们如何在 jQuery 中获取 html 表格的高度。例如,如果我们有以下代码,那么我们如何获得表格的高度:-
<table>
<tr>
<td>
<div>Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here </div>
</td>
<td>
<div>Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here Some Text Here </div>
</td>
</tr>
</table>
回答by elclanrs
What about $('table').height()
or even $('table').outerHeight()
.
怎么样$('table').height()
,甚至$('table').outerHeight()
。
回答by Dr.Kameleon
With a table like this :
有这样一张桌子:
<table id="abc">
...
</table>
The jQuery needed in order to get the height of the above table is :
为了获得上表的高度所需的 jQuery 是:
var height = $('#abc').height();
var height = $('#abc').height();