คำตอบที่ได้รับเลือกจากเจ้าของกระทู้
ความคิดเห็นที่ 3
ลองดู
.querySelectorAll("div.ag-row")
หรือ
.querySelectorAll("div.ag-row.ag-row-not-inline-editing")
.querySelectorAll("div.ag-row.ag-row-level-0-on-absolute")
CSS class selector
https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors
.querySelectorAll("div.ag-row")
หรือ
.querySelectorAll("div.ag-row.ag-row-not-inline-editing")
.querySelectorAll("div.ag-row.ag-row-level-0-on-absolute")
CSS class selector
https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors
แสดงความคิดเห็น
javascript ต้องการ extract ตาราง จาก html ที่เป็น div จึงพยายามจับจาก class name
const tbl = document.getElementsByClassName('ag-root ag-unselectable ag-layout-auto-height')[0];
const header_selection = tbl.getElementsByClassName("ag-header-viewport")[0];
const header = header_selection.innerText.split("\n");
// บรรทัดนี้คือปัญหา ที่อยากขอคำแนะนำ
const cellvalues = tbl.querySelectorAll('[class="ag-cell-value"]');
Object.entries(cellvalues).map(
cell=> {
console.log(cell.innerText)
}
);
[/code]
เวลา log ออกมา เป็น undefind หมดเลยหนะครับ
ต้องแก้โค๊ดผมเรียกใช้ อะไร ผิดไปทำให้มันไม่ได้ value ออกมาครับ ขอบคุณครับ
ผลที่ได้ เป็น undefind
[img]https://f.ptcdn.info/716/082/000/s60uqy41leWsci3Zw7Vp-o.png[/img]
html source มี class ที่ระบุ
[img]https://f.ptcdn.info/716/082/000/s60uqy2c9xx1S4ognzIcm-o.png[/img]
ขอบคุณครับ