Skip to content

Instantly share code, notes, and snippets.

@mckabi
Last active August 21, 2019 02:56
Show Gist options
  • Save mckabi/87149e73e5f94bd0ac47ccecea11a099 to your computer and use it in GitHub Desktop.
Save mckabi/87149e73e5f94bd0ac47ccecea11a099 to your computer and use it in GitHub Desktop.
document.querySelectorAll("td[colspan=full]").forEach(td => {
const table = td.closest("table");
const columns = table.querySelector("tr").querySelectorAll("th, td");
const column_count = Array.from(columns).reduce((acc, cell) => acc + (cell.getAttribute('colspan') || 1), 0);
td.setAttribute('colspan', column_count);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment