我已经在jquery 选择器中搜索了一段时间,但找不到任何解决我的问题的方法。
我有一个由foreach提交的 html 表。在每一行上,有几个链接会弹出工具提示。我的问题:找不到正确的选择器。
<table>
<?php foreach($article) :?>
<tr>
<td>
<div class="none" style="display:none;">
<div class="tooltip_1">
"The content of my tooltip_1"
</div>
<div class="tooltip_2">
"The content of my tooltip_2"
</div>
</div>
<div class="cell">
<a href="#" class="link_to_tooltip_1">a link</a>
<a href="#" class="link_to_tooltip_2">a link</a>
</div>
</td>
<tr>
<?php endforeach; ?>
</table>
为了显示我的工具提示,我使用qTip,它的工作方式如下:
$('a[class="link_to_tooltip_1"]').qtip({
content: $('jquery selector'),
(... other options)
});
所以基本上,我需要类似的东西
content: $('self.parentNode.parentNode > div[class="none"] > div[class="tooltip_1"]'),
换句话说 :
- 从链接“link_to_tooltip_1”开始
- 返回父 div“单元格”
- 回到父 td
- 然后转到子 div“无”
- 最后选择子div“tooltip_1”
非常感谢。