$('tr:odd').css('background', '#FF00FF');---这个可以$('table.striped>tr:even').css('background', 'red');--这个就是不灵,不知道为什么

解决方案 »

  1.   

    $('table .striped >tr:even').css('background', 'red');
      

  2.   

    还是不行呀
    我 是 jquery-1.3.2.min.js 的
      

  3.   

    是类 选择器,选择 class 列表中包含 striped 的对象
      

  4.   

    $('table.striped tr:even').css('background', '#FF00FF'); 这个可以
    $('table.striped >tr:even').css('background', '#FF00FF'); 不行,为什么
      

  5.   

    <table class="striped" border="1" cellpadding="0" cellspacing="0" width="100%" >
      <tr >
        <td width="25%"></td>
        <td width="25%"></td>
        <td width="25%"></td>
        <td width="25%"></td>
      </tr>
      <tr>
        <td width="25%">a</td>
        <td width="25%">d</td>
        <td width="25%">a</td>
        <td width="25%">a</td>
      </tr>
      <tr>
        <td width="25%">b</td>
        <td width="25%">d</td>
        <td width="25%">a</td>
        <td width="25%">a</td>
      </tr>
      <tr>
        <td width="25%">c</td>
        <td width="25%">d</td>
        <td width="25%">a</td>
        <td width="25%">a</td>
      </tr>
    </table>
    $('table .striped >tr:even').css('background', 'red');
     哪里有问题
      

  6.   

    因为tr的直属parentNode不是table,而是tbody
      

  7.   

    你可以试下$('tbody>tr:even').css('background', 'red');
      

  8.   

    楼上说的对
    $('table.striped tbody >tr:even').css('background', 'red');