类最接近父在下面的结构JQuery的查找与
<div class="thisNot">
<table style="width:100%" class="thisOneUknow">
<tr>
<th id="imhere">Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
</div>
如果我在$(“#imhere”),我如何才能找到一类最接近的父母和提取价值?在这种情况下获得thisOne(总以为是我站在imhere元素)
编辑:自动生成的类thisOneOknown,所以这个改变在每个页面加载,所以选择已经能够找到的第一个父同类并存储/返回它。 Somethinng like var closestParentClass = $('#imhere')。closest(“:hasParent()”);编辑的问题后
看起来这将是简单的谷歌和发现,除非那里有我丢失的东西?你有没有[在这里读过这个问题](http://stackoverflow.com/questions/5333426/how-to-find-a-parent-with-a-known-class-in-jquery)? – crazymatt
$(“#imhere”)。parents(“[class]”)。添加链接到文档https://api.jquery.com/has-attribute-selector/ – Jules
是的,我错过了一个非常重要的细节:类thisOne对我来说是未知的,所以选择器.thisOne不是我的选择。对不起,我要编辑的问题 –