繁体   English   中英

我不能替换来自数据库的html主体中的文本

[英]I can not replace the text in a html body that comes from the database

我想用来自数据库的p标签替换文本'$$$_img1_$$$'

$("body").children().each(function() {

    $(this).html($(this).html().replace('$$$_img1_$$$', variable_name));
});


$("body").children().each(function() {

    $(this).html($(this).html().replace('$$$_img1_$$$', "hahahhah"));
});

如果variable_name包含img标记,则'$$$_img1_$$$'将替换为图像标记<img src = ''>

试试这段代码:

$('body').each(function() {
   var replaced = $("body").html().replace('$$$_img1_$$$','The ALL new string');
   $("body").html(replaced);
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM