Want to get all elements from the table [duplicate]

本秂侑毒 提交于 2019-12-11 10:32:50

问题


i have a website login: cyclefreight1@usa.com pas: 12345678, log in and go to the drivers section(left menu bar firs item > drivers) I want to make some additional function to this web with tampermonkey, i try to get all elements from the table, i do it with selector like this

var rows = document.querySelectorAll("#app table.table-component tr");

but all i have is undefined ^( , please give me some tips how can i do it, thank you


回答1:


The table is inside an iframe on another domain, so it's tricky to access. Include the userscript on that other domain, and give it a setTimeout to give the table time to populate:

// ==UserScript==
// @name         drivers
// @match        https://eldclient.trackingmap.eu/drivers*
// @grant        none
// ==/UserScript==

setTimeout(() => {
  const rows = document.querySelectorAll("#app table.table-component tr");
  console.log(rows);
}, 2000);


来源:https://stackoverflow.com/questions/50327158/want-to-get-all-elements-from-the-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!