I have this code:
function getRowValue() {
var table = document.getElementById('employee-table');
var cells = table.getElementsByTagName('td');
for (var i = 0; i < cells.length; i++) {
// Take each cell
var cell = cells[i];
// do something on onclick event for cell
cell.onclick = function () {
// Get the row id where the cell exists
var rowId = this.parentNode.rowIndex;
var rowsNotSelected = table.getElementsByTagName('td');
var rowSelected = table.getElementsByTagName('tr')[rowId];
msg = rowSelected.cells[0].innerHTML;
alert(msg);
return msg;
}
}
}
getRowValue();
alert(msg);
How can I access value of msg outside the function. I've tried with return on different places, push it to array, return false in loop ---- no result. Thanks!