【问题标题】:How to get the height of table in JqueryJquery如何获取表格的高度
【发布时间】:2017-01-03 04:00:50
【问题描述】:

我们如何在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>

【问题讨论】:

    标签: jquery html css html-table


    【解决方案1】:

    $('table').height() 甚至 $('table').outerHeight() 呢?

    【讨论】:

    • 如果表有 id="abc",如何将其存储在变量中
    • @JohnPreston 为什么不先学习 jQuery 选择器语法?
    【解决方案2】:

    也许this

    var height = $('#abc').height();
    

    【讨论】:

      【解决方案3】:

      这样的表:

      <table id="abc">
            ...
      </table>
      

      获取上表高度所需的jQuery是:

      var height = $('#abc').height();

      【讨论】:

        猜你喜欢
        • 2018-07-03
        • 2011-05-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-26
        • 1970-01-01
        • 2016-06-20
        • 1970-01-01
        相关资源
        最近更新 更多