【发布时间】:2014-02-04 04:54:08
【问题描述】:
是否可以用另一个短语替换 HTML 文档中的短语?我不确定 JavaScript 是否可以做到这一点,但这里有一个例子:
String thePhrase = "this is the phrase to replace";
String toReplace = "this is the phrase that replaces thePhrase";
replace(thePhrase, toReplace);
然后这样的东西会在 HTML 文档中搜索并用 toReplace 替换 thePhrase。
感谢任何可以提供帮助的人。
【问题讨论】:
-
你查过什么吗?
-
您需要将文档中的所有文本从 X 替换为 Y?
-
在源头替换数据,而不是在加载客户端。或者在 PHP 中执行此操作。
-
@dystroy 是因为这个stackoverflow.com/questions/21140844/…
-
使用 querySelectorAll 获取您的
link元素并在这些元素的 innerText/textContent 上进行替换
标签: javascript html