Javascript 计算'的数量;表';使用jquery的标记

Javascript 计算'的数量;表';使用jquery的标记,javascript,jquery,html,css,jquery-plugins,Javascript,Jquery,Html,Css,Jquery Plugins,这是我的HTML代码 <div class="tableStyle myWebsiteTable"> <table cellspacing="0" cellpadding="0" id="site0" class="site active"> <thead> <tr> </tr> </thead>

这是我的HTML代码

      <div class="tableStyle myWebsiteTable">
      <table cellspacing="0" cellpadding="0" id="site0" class="site active">
        <thead>  
            <tr>  

            </tr>  
        </thead>
        <tbody>
            <tr class="websiteDetails">
                <td colspan="5">
                <div id="websiteDetails0" class="divWebsiteDetails" style="display: block;">
                    <table>
                        <tbody>
                                                        <tr id="190">
                                <td>index</td>
                                <td></td>
                                <td></td>
                            </tr>
                             <tr class="addPage">
                                <td align="center" colspan="5"></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                </td>
            </tr><!--Website Details-->
        </tbody>
      </table>
                <table id="addNewSiteTable">
        <thead> 
          <tr>               
          </tr>
         </thead> 
      </table>
</div>`<br/>

指数
`
现在,表被动态添加到此结构中。我想根据第一个
div
中表的编号编写一些逻辑。我尝试了这样做,但没有成功
$('myWebsiteTable')。children('table')。length)

请建议实现这一目标的正确方法
谢谢

上课前你需要使用

$('.myWebsiteTable').children('table').length
还要确保您已经添加了jQuery,并且元素已经添加到DOM中

您可能需要使用as-children,因为它只提供一级children,而as-find将获得子体中的所有表

$('.myWebsiteTable').find('table').length 
我想这是一门课

$('.myWebsiteTable')

如果确实要计算嵌套表的数量:

$('.myWebsiteTable table').length

试试这个,这对你更有帮助


演示

那太愚蠢了!!!!!!!!!工作到很晚会产生严重的影响!!我现在同意了!
$('.myWebsiteTable table').length