Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"));
like image 598
maddogandnoriko Avatar asked Feb 11 '12 16:02

maddogandnoriko


1 Answers

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.

like image 102
ShankarSangoli Avatar answered Sep 18 '22 01:09

ShankarSangoli