我有一个股票市场插件,可以显示当前的股票值(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/