Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js html table extract data

const extractData = (tableId, mapper) => {
  const myTab = document.getElementById(tableId);
  if (myTab) {
    const data = [...myTab.rows].map((r) => [...r.cells].map((c) => c.innerText));
    return data.map(mapper);
  }
};

// Call the function and do whatever you want with the data
const data = extractData('target-table', (x) => ({
  name: x[0]
}));
 
PREVIOUS NEXT
Tagged: #js #html #table #extract #data
ADD COMMENT
Topic
Name
9+3 =