开发者社区 问答 正文

关于jQuery的Dom的remove操作问题

$(this).nextAll().find("iframe").remove();
$(this).nextAll("iframe").remove();
$(this).nextAll().remove("iframe");

为什么只有第三句能删掉?(this是iframe前面的一个元素)
有区别吗?

展开
收起
吴孟桥 2016-05-31 14:52:50 1861 分享 版权
1 条回答
写回答
取消 提交回答
  • $(this).nextAll().find("iframe").remove(); 这个是在this对象的同级节点下找iframe

    $(this).nextAll("iframe").remove(); 这个是找this对象同级节点后的iframe节点,应该是可以删除this后的iframe的

    $(this).nextAll().remove("iframe");这个是第二句效果效果类似

    2019-07-17 19:21:57
    赞同 展开评论