gpt4 book ai didi

javascript - 使用javascript从表中提取数据

转载 作者:行者123 更新时间:2023-12-05 02:20:33 26 4
gpt4 key购买 nike

我正在使用 healcode显示mindbody我网站上的数据。我正在使用 healcode 小部件,问题是我只能更改 CSS 而不能触摸 HTML 小部件将数据传递到一个表中,这对我的需求非常有限.我希望能够创建 html 结构,或者至少操作当前结构。

是否可以使用 CSS 或 Javascript 或两者从表格中提取内容和数据并重新创建我选择的 HTML 结构?

最佳答案

当然,您可以通过 JavaScript 完成此操作,尽管这是一个相当宽泛的问题。你必须得到你需要操作的表元素(比如说,如果它有和 id someId,你必须使用 var table = document.getElementById('someId');),然后使用 DOM API 操作它的 table.innerHTML(可能是一个很好的起点)或它的子代:比如说,对于 this page (“参数值”表)您可以在浏览器控制台中尝试:

// first table with the "w3-table-all notranslate" class
var table = document.getElementsByClassName("w3-table-all notranslate")[0];

table
.children[0] // will get the tbody element
.children[1] // will get the second row from the tbody element
.children[0] // will get the first (colomn) cell in the second row
.innerHTML; // will show you html contents of the cell in the console

// change the cell contents
table.children[0].children[1].children[0].innerHTML = "<b>I've changed this stuff!</b>";

// you may also want to remember rows/cells:
var row = table.children[0].children[1];
var cell = row.children[0];

基本上就是这样。

关于javascript - 使用javascript从表中提取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38731882/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com