javascript - 使用Jquery选择器选择div的子元素

标签 javascript jquery html

我使用了两个具有相同类名的不同表,并将其放置在不同的 div 中,如下代码片段所示。

代码片段:

 <div>
    <div class="gridheader scrollcss">
        <div>
            <table class="table" style="position: relative;" cellspacing="0">
                <colgroup>
                    <col style="width: 160px;">
                    <col style="width: 160px;">
                    <col style="width: 160px;">
                    <col style="width: 160px;">
                    <col style="width: 160px;">
                </colgroup>
                <thead>
                    <tr class="columnheader" style="cursor: pointer;">
                        <th class="headercell"><div class="headercelldiv">Taskname</div></th>
                        <th class="headercell"><div class="headercelldiv">Starttime</div></th>
                        <th class="headercell"><div class="headercelldiv">Endtime</div></th>
                        <th class="headercell"><div class="headercelldiv">Duration</div></th>
                        <th class="headercell"><div class="headercelldiv">Status</div></th>
                    </tr>
                </thead>
                <tbody class="hide">
                    <tr><td></td><td></td><td></td><td></td><td></td></tr>
                </tbody>
            </table>
        </div>
    </div>

<div class="gridcontent" style="height: 462px; overflow: auto;">
    <div class="gridcontainer" style="height: 420000px;">
        <table class="table" style="position: relative;" cellspacing="0">
            <colgroup>
                <col style="width: 160px;">
                <col style="width: 160px;">
                <col style="width: 160px;">
                <col style="width: 160px;">
                <col style="width: 160px;">
            </colgroup>
            <tbody>
                <tr><td class="rowcell">1</td><td class="rowcell">01/01/2013</td><td class="rowcell">01/05/2013</td><td class="rowcell">0 days</td><td class="rowcell">2</td></tr>
            </tbody>
        </table>
    </div>
  </div>
</div>

如何使用jquery选择器选择gridcontainer div中的第二个表格位置并仅应用该表格的样式

最佳答案

$('.gridcontainer table').css(/*your styles*/);

关于javascript - 使用Jquery选择器选择div的子元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20158181/

相关文章:

javascript - 将 JavaScript 字符串拆分为固定长度的片段

javascript - GET http ://js:port/socket. io/1/404 未找到

javascript - 深度克隆对象数组

javascript - 如何使用逗号JS从数组中输出数据列表?

javascript - jQuery 数据表 : Pass returned JSON to a variable

javascript - 在 JQuery 中克隆时更改名称属性

javascript - 获取 span 标签 HTML 的值

javascript - 使用 jQuery 将光标更改为图像

jquery - 使用替代文本实现悬停效果

javascript - 带计算的 Angular 数据绑定(bind)