How do you check in JS what the value of the td above the current one is in a table? I'm trying to get a table like this:
|column1 | column2 | column3 | column4 |
----------------------------------------
| | | | |
----------------------------------------
| | | data | |
----------------------------------------
| | | data | fox |
----------------------------------------
| | bacon | | |
----------------------------------------
| | | | |
To look like this:
|column1 | column2 | column3 | column4 |
----------------------------------------
| | | | |
----------------------------------------
| | | | |
-------------------- data -----------
| | | | fox |
----------------------------------------
| | bacon | | |
----------------------------------------
| | | | |
My plan was to loop through each td element, to check the html of that td, then the one above, and if they are equal, hide the bottom one, and set the rowspan of the top one to 2.
I'm having trouble iterating through the td elements, I've tried some jQuery like this:
$("#myTable td").each(function(){
console.log($(this).html())
});
But I can't access easily the cell above/below the current one. Any ideas?