相当于jquery中的html body替换

时间:2018-03-05 18:44:44

标签: javascript jquery

jquery中的等价物是什么?

document.body.innerHTML = document.body.innerHTML.replace("text1", "text2");

谢谢

1 个答案:

答案 0 :(得分:0)

$("body").html(function(){
   return $(this).html().replace("text1", "text2");
})

回调函数将返回当前的html替换文本,值将设置为html。