【发布时间】:2015-07-05 04:49:02
【问题描述】:
这个问题可能是重复的,但我没有发现任何有用的信息。
这是我的 sn-p:
$("table tbody tr").hover(
function() {
var secondCell = $(this).children[1].textContent;
//secondCell.someCode
},
function() {
//some code
}
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<thead>
<tr>
<th>foo</th>
<th>foo</th>
<th>foo</th>
</tr>
</thead>
<tbody>
<tr>
<td>bar</td>
<td>bar</td>
<td>bar</td>
</tr>
</tbody>
</table>
我想做的就是:当玩家悬停一行时,它应该提醒他们一条消息,并且该消息具有第二个单元格文本。
希望您能明白这一点,并在此先感谢您。
【问题讨论】:
-
$( "tr td:nth-child(2)" ) 应该成功了。