Skip to content

Instantly share code, notes, and snippets.

@SamuelAwojuola
SamuelAwojuola / getTableCell.js
Created October 15, 2019 18:59 — forked from nikitaeverywhere/getTableCell.js
JavaScript function that returns the cell of the table by given coordinates considering colSpan and rowSpan of the cells.
/**
* Returns the cell of the table by given (x;y) coordinates considering colSpan and rowSpan of the cells.
* @param {HTMLElement} table - HTML table
* @param {number} x - X position in table matrix
* @param {number} y - Y position in table matrix
* @returns {HTMLElement|null}
*/
var getTableCell = function (table, x, y) {
var m = [], row, cell, xx, tx, ty, xxx, yyy;
for(yyy = 0; yyy < table.rows.length; yyy++) {