jQuery回归2个父母

时间:2016-01-25 17:22:03

标签: javascript jquery html

嘿所有我想要得到以下标签:

<tr class="grid-layout-row">

在此HTML中:

<tr class="grid-layout-row">
    <td role="presentation" class="grid-layout-row-leader">
        <div class="grid-layout-row-leader-spacer"></div>
    </td>
    <td role="presentation" class="grid-layout-cell  F_Form1-P_NewPage-F_DatePosted_cell">
            ....... lots of code here
    </td>
</tr>

从此标签开始:

<td role="presentation" class="grid-layout-row-leader">
    <div class="grid-layout-row-leader-spacer"></div>
</td>

我试过了:

var curr = $('td[class*=-F_DatePosted_cell').parent().prev();

但是之前似乎拿起了标签:

<tag here that it gets>
<tr class="grid-layout-row">

我会失踪什么?

2 个答案:

答案 0 :(得分:5)

不要使用def repeat?(year) not (year.to_s.chars == year.to_s.chars.uniq) end puts(repeat?(1702)) #=> false puts(repeat?(1997)) #=> true puts(repeat?(2001)) #=> true puts(repeat?(1800)) #=> true 因为结构随时间而变化,最佳做法是不依赖于DOM中的精确位置。使用parent向前移动到匹配选择器的第一个父级,如下所示:

closest

答案 1 :(得分:-2)

你应该使用parent()。

-(IBAction)goBack:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(IBAction)goHome:(id)sender
{
    [self.delegate ViewControllerCWillGoHome:self];
   [self dismissViewControllerAnimated:YES completion:nil];
}