我需要检索单击的单元格上方单元格的底部边框宽度。
var $this = $(this);
var col = $this.parent().children().index($this);
var row = $this.parent().parent().children().index($this.parent());
var bordWidth= ($this.parents('tr:eq('+(row-1)+')').find('td:eq('+col+')').css("border-bottom-width"));
最佳答案
试试这个。
var $this = $(this);
var $tr = $this.parent();
var col = $tr.children().index($this);
var bordWidth = $tr.prev().children().eq(col).css("border-bottom-width");
.prev()
将获取前一个 tr
元素,然后使用 .children()
获取所有 td
并使用 eq()
方法获取所需的 td。
关于jquery - 从上面的单元格获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9242013/