Get data from the cell above

I need to get the width of the bottom border of the cell above the clicked cell.

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"));
+5
source share
1 answer

Try it.

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()will get the previous element tr, and then with the help it .children()will get everything tdand get the required td using the method eq().

+10
source

All Articles