search

Home  >  Q&A  >  body text

.replaceWith( newContent ):用提供的内容替换集合中所有匹配的元素并且返回被删除元素的集合 返回被删除元素的集合怎么体现出来?

小白小白2937 days ago1020

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 23:00:43

    .replaceWith( newContent ): Replace all matching elements in the collection with the provided content and return the collection of deleted elements. How to return the collection of deleted elements? -PHP Chinese website Q&A-.replaceWith(newContent): Replace all matching elements in the collection with the provided content and return the collection of deleted elements. How to return the collection of deleted elements? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 迷茫

    迷茫2016-12-19 17:37:51

    设置一个变量用.replaceWith( newContent )返回值赋值就可以看到被删除元素了,比如例子中添加del变量如下:

     var del = $(".right > div:first p:eq(1)").replaceWith('<a style="color:red">replaceWith替换第二段的内容</a>');

            document.write(del.html());

    可以看到打印“第二段”就是返回值了


    reply
    0
  • Cancelreply