javascript - 使用 Javascript 更改 TH 中的文本

标签 javascript jquery html css

我有一个股票市场插件,可以显示当前的股票值(value)。 现在我想使网站多语言并尝试使用 javascript 进行更改(静态)。

<table>
<thead>
  <tr>
          <th>Symbol</th>
          <th>Name</th>
          <th class="smw-tablesort smw-Decimal">Aktueller Marktwert</th>
          <th class="smw-tablesort smw-Decimal">Änderung</th>
          <th class="smw-tablesort smw-Percent">Änderung in %</th>
        </tr>
</thead>
<tbody></table>

我尝试了以下代码:

document.body.innerHTML = document.body.innerHTML.replace('Name', 'Start');

但是没用

来自插件的数据带有一个 env.joson 文件。所以它们是文本字符串。我只能翻译一种语言,但我需要 3 种语言。

最佳答案

仅基于我们在您的帖子中看到的代码。

document.querySelectorAll('th')[1].style.color = "blue";

我正在找到第二个 TH 标签并以此方式设置颜色。您也可以通过这种方式设置值。

document.querySelectorAll('th')[1].innerText = "start";
or 
document.querySelectorAll('th')[1].innerHTML = "start";

关于javascript - 使用 Javascript 更改 TH 中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55229500/

相关文章:

javascript - YouTube iFrame API : Programmatically play natively?

javascript - 解析 JSON 响应时出现问题

javascript - 是否可以通过该函数之外的操作退出 javascript 中的递归函数?

javascript - 我想显示来自数据库的数据。如果我们新添加一个表单数据,我想使用 codeigniter 在不刷新的情况下附加显示的新帖子

html - 如何在 Bootstrap 表单上放置背景图片?

javascript - 使用 javascript 刷新莫里斯图

jquery - 如何在 jquery 中获取 div 计数?

javascript - 通过 json 检索动态数据

html - Twitter Bootstrap 选项卡和 bootstrap-select 溢出问题

javascript iframe 卸载