我正在使用此方法查找並替換一段文本,但不確定它爲什麼不起作用?當我使用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