我需要找到和.replaceWith一些文本,例如:
absdef 替换为 111111
abcdefgiop 替换为 22222222
但是当我的文字看起来像是
abcdef,abcdefgi
.replaceWith对我来说工作很差,我得到这样的东西:
111111 ,111111giop
我使用此代码:
$("*").contents().each(function() {
if(this.nodeType == 3)
this.nodeValue = this.nodeValue.replace("absdef", "111111");
});
//
$("*").contents().each(function() {
if(this.nodeType == 3)
this.nodeValue = this.nodeValue.replace("abcdefgiop", "22222222");
});
答案 0 :(得分:0)
撤销订单并连接它们。
$("*").contents().each(function() {
if(this.nodeType == 3)
this.nodeValue = this.nodeValue.replace("abcdefgiop", "22222222")
.replace("abcdef", "111111");
});