我正在使用此方法查找并替换一段文本,但不确定它为什么不起作用?当我使用console.log时,我可以看到我想要替换的正确内容,但最终结果不起作用:jQuery替换文本不起作用
(function($) {
$(document).ready(function() {
var theContent = $(".transaction-results p").last();
console.log(theContent.html());
theContent.html().replace(/Total:/, 'Total without shipping:');
});
})(jQuery);
有什么想法?
谢谢!
与string.replace返回一个字符串 - 它不会做的替换字符串引用...'theContent.html(theContent.html()。replace(/ Total:/,'Total shipping:'));' – Archer
@diEcho这不是PHP,你不包装正则表达式引号。 – Barmar