js方法加正则 替换标签

  var body = "<img style='adfs' class='container'>test</img></b>";
   var result = body.replace(/img/gi,'like');
   console.log(result);//<like style='adfs' class='container'>test</like></b>

猜你喜欢

转载自blog.csdn.net/weixin_51426266/article/details/127413096