-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
32 lines (22 loc) · 701 Bytes
/
script.js
File metadata and controls
32 lines (22 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const exportBtn = document.querySelector("#exportBtn");
const exportData = () => {
const table = document.querySelector(".table");
const rows = table.querySelectorAll("tbody tr");
const data = [];
rows.forEach((row) => {
const cells = row.querySelectorAll("td");
const rowData = {
col1: cells[0]?.textContent.trim(),
col2: cells[1]?.textContent.trim(),
col3: cells[2]?.textContent.trim(),
};
data.push(rowData);
});
return data;
};
exportBtn.addEventListener("click", async () => {
const data = exportData();
const text = JSON.stringify(data, null, 2);
await navigator.clipboard.writeText(text);
alert("Copied to clipboard:", text);
});