Jquery:从元素中获取下一个元素
如何从 td rowspan=4 获取目标
不确定:
$("#fromTd").parent("tr").next().eq($("#fromTd").attr("rowspan")-1)
<table>
<tr>...</tr>
<tr>...</tr>
<tr><td id="fromTd" rowspan="4"></td></tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr> -> target (can be aleatory position..)
</table>
How can I get the target from the with td rowspan=4
Not sure about:
$("#fromTd").parent("tr").next().eq($("#fromTd").attr("rowspan")-1)
<table>
<tr>...</tr>
<tr>...</tr>
<tr><td id="fromTd" rowspan="4"></td></tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr> -> target (can be aleatory position..)
</table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我错了,请纠正我,但听起来您想要的是在 X 行之后获取下一个
,其中 X 是给定
的行跨度> - 1. 换句话说,您希望
不会扩展到下一行。
如果是这种情况,这应该可以解决问题:
这是一个现场演示: http://jsfiddle.net/wLPA9/< /a>
Correct me if I am wrong but it sounds like what you want is to get the next
<tr>
after X rows where X is the rowspan of a given<td>
- 1. In other words, you want the next row into which that<td>
will NOT extend.If that is the case, this should do the trick:
Here's a live demo: http://jsfiddle.net/wLPA9/
如果您尝试执行该行的操作(选择当前单元格
rowspan
末尾之后的行),您只需要nextAll()
而不是next()
,它只返回紧邻的下一个同级元素。或者,如果您有很多后续行,并且不想选择所有行来选择单个行,则可以使用标准 DOM
rows
和 <代码>rowIndex属性:If you're trying to do what that line looks like it's trying to do—selecting the row after the end of the current cell's
rowspan
—you would just neednextAll()
instead ofnext()
, which only ever returns the immediate next element sibling.Alternatively if you've got lots of following rows and you don't want to have to select them all to pick a single one out, you could do it slightly more efficiently with the standard DOM
rows
androwIndex
properties: