gpt4 book ai didi

javascript - jQuery 搜索和替换不起作用(Wordpress)

转载 作者:行者123 更新时间:2023-12-02 14:55:40 24 4
gpt4 key购买 nike

我一定已经尝试了六个脚本(大多数可以在此处找到,例如 jQuery find and replace string )来替换我的 Wordpress 构建的网站 ( http://www.sehkelly.com/ ) 上的文本。

没有任何作用。我不够聪明,无法诊断原因(但也没有愚蠢到不知道如何运行脚本)。脚本以通常的方式进入 header.php,但没有结果。

例如,我的主页上的所有“Shop”实例(在菜单中、h2 元素中、Wordpress 内容中)都保持原样,尽管有此脚本...

$("span, p, div").each(function() {
var text = $(this).text();
text = text.replace("Shop", "Sale");
$(this).text(text);
});

有什么想法吗?

我禁用了缓存插件,但没有效果。

提前致谢。

更新

我有完整的...

<script type="text/javascript">
$(document).ready(function(){
$("span, p, div").each(function() {
var text = $(this).text();
text = text.replace("type", "typo");
$(this).text(text);
});
</script>

还是没有喜悦。

最佳答案

如果你在你的网站上执行这样的代码,它会在你的 html 中造成困惑......不要这样做:)

这样做:

$("span, p, div").each(function() {
var text = $(this).html();
text = text.replace("Shop", "Sale");
$(this).html(text);
});

关于javascript - jQuery 搜索和替换不起作用(Wordpress),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35813160/

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