【发布时间】:2017-09-25 00:08:35
【问题描述】:
当我单击 iframe 中表格的表格单元格时,我希望能够找出一行中有多少个单元格,如果单元格是跨度,我希望能够将跨度用作细胞计数。
框架可以包含许多没有类的表,但我无法得到计数,它比应该的要高得多
iframe.find('td').click(function () {
var thisCell = $(this);
var thisRow = thisCell.closest('tr');
var thisTbody = thisRow.closest('tbody');
var thisTable = thisRow.closest('table');
var url = "@(Html.Raw(Url.Action("_TableAttr")))";
var d1 = $.Deferred();
$.when(d1).then(function () {
var tds = $(thisTable).children('tbody').children('tr').children('td').length;
alert(tds);
});
d1.resolve(LoadNewsSideBarContent(url));
我尝试了一个循环遍历表的 .each 函数 > tbody> 行 > td 但仍然很奇怪。我觉得我在变量中存储表格的方式是错误的?
【问题讨论】: