jQuery selector problem. :last-child not doing what I need
什么样的jQuery选择器可以让我选择
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <table> <tr> <td colspan="2">First Cell</td> <td>Second Cell</td> </tr> <tr> <td colspan="2">Only Cell</td> </tr> <tr> <td>First Cell</td> <td>Second Cell</td> <td>Third Cell</td> </tr> </table> |
起初,我以为td:last-child可能有用,但没有用。
尝试使用此选择器:
1 | td:last-child:not(:first-child) |
说明:在您的情况下,最后一个孩子也是第一个孩子,因为它是父元素的唯一孩子。如果现在仅选择不是其父元素的第一个子代的最后一个子代,则将仅获得不是其父元素的唯一的子代的最后一个子代。