2013-11-23 2 views
1

Я использую две разные таблицы с одним и тем же именем класса и размещен в разных div, как показано ниже.Использование селектора JQuery для выбора дочернего элемента 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 и применить стиль для этой таблицы только

+0

'$ ('gridcontainer:. эк (1)'). найти ("таблица")' должна возвращать вторую таблицу, если тот, что вы просите – megawac

ответ

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

условии решение для меня. спасибо – Raja

0

To sel ЕСТ второй стол можно использовать .eq():

var secondGridTable = $('.gridcontainer:eq(1)').find("table") 
Смежные вопросы