maddogandnoriko
maddogandnoriko

Reputation: 1002

Get data from above cell

I need to retrieve the bottom border width 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"));

Upvotes: 7

Views: 3499

Answers (1)

ShankarSangoli
ShankarSangoli

Reputation: 69915

Try this.

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 tr element and then using .children() get all the td's and get the required td using eq() method.

Upvotes: 12

Related Questions