[英]jquery table find closest tr containing and get td text
This datatables has row-reordering so its drag and drop. 该数据表具有行重新排序,因此它可以拖放。 What I am trying to do is find the Parent this row is dropped into and get the Parent id.
我想做的是找到该行放入的Parent,并获取Parent ID。 Hopefully someone can tell me where I am going wrong...
希望有人可以告诉我我要去哪里错了...
This line successfully gives me the tr id 这行成功地给了我TR ID
var line = parseInt($(this).attr('id'));
So I'm using this to get the closest above Parent (check the image) 所以我正在使用它来获取最接近父级的上方(检查图像)
var s = $(this).find('tr:contains("Parent")');
What I can't seem to do is get to any td value 我似乎无法做到的是获得任何td值
var s = $(this).find('tr:contains("Parent")').find('td:eq(17)').text()
I've also tried this 我也试过了
var s = $(this).closest('tr').prevAll('tr.Parent:first > td:nth-child(17)').text()
Link to an image of the table http://postimg.org/image/rlamm9osd/ 链接到表格的图片http://postimg.org/image/rlamm9osd/
jsfiddle with table code http://jsfiddle.net/Lmcfccmo/ 带有表代码的jsfiddle http://jsfiddle.net/Lmcfccmo/
It looks like you want to simply take the "parent ID" value from column (index 14) and use it to find the row that simply has ID="that parent number"
: 看来您只想从列(索引14)中获取“父ID”值,并使用它来查找仅具有
ID="that parent number"
the ID="that parent number"
:
eg 例如
var parent = $('#' + $(this).children().eq(14).text());
JSFiddle: http://jsfiddle.net/TrueBlueAussie/Lmcfccmo/5/ JSFiddle: http : //jsfiddle.net/TrueBlueAussie/Lmcfccmo/5/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.