Skip to content

Instantly share code, notes, and snippets.

@mamedshahmaliyev
Created October 26, 2020 07:04
Show Gist options
  • Save mamedshahmaliyev/455e7f0d032c1460a2e1ee6375d2489d to your computer and use it in GitHub Desktop.
Save mamedshahmaliyev/455e7f0d032c1460a2e1ee6375d2489d to your computer and use it in GitHub Desktop.
Populate or fill HTML table with random data in vanilla JavaScript
var table_selector = '#table_id';
var i = 0;
var content_length = 15;
document.querySelectorAll(table_selector + ' tr').forEach((row, i) => {
row.querySelectorAll('td').forEach((td, j) => {
td.innerHTML = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, content_length);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment