document.addEventListener("DOMContentLoaded", () => {
let tab = document.getElementById("tab");
tab.onclick = e => {
let cell = e.target;
let row = cell.parentElement;
let rows = row.parentElement.children;
for (var i = 0; i < rows.length; ++i) {
if (rows[i] === row) {
break;
}
}
let columns = row.children;
for (var j = 0; j < columns.length; ++j) {
if (columns[j] === cell) {
break;
}
}
alert('Row: ' + i + ', Column: ' + j);
};
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<script>
let str = "First: 231\nSecond: some_text\nThirth: 88"
let reg = /:\s*(.*)$/gium;
let obj = [];
let i = 0;
for(let match = reg.exec(str); match !=null; match = reg.exec(str))
{
obj[i++] = match[1];
}
console.log(obj);
document.write("-------------");
</script>
</body>
</html>