Accessing table cells in JS

Hi, great that AP9 now has tables.
Is it possible to read out the content of a table cell with JS.


Hi Rolf,

You can use the following function to achieve that:

function getTableCellText(tableName, rowIndex, columnIndex) {
  var objectNode = prez.object(tableName).node;
  return $('table tr:nth-child(' + rowIndex + ') td:nth-child(' + columnIndex + ')', objectNode).text();

For example, this is the code to get the text in the cell located at row 2, column 3:
getTableCellText('table object name', 2, 3)


Excellent, Hang, thank you!
Best, Rolf

1 Like