jquery中的文档操作之四

removeAttr() 方法从被选元素中移除属性 $("p").removeAttr("style");

removeClass() 方法从被选元素移除一个或多个类。如需移除若干类,请使用空格来分隔类名。$("p:first").removeClass("intro");

感觉这个在使用是不会遵循 一定要把c使用currentClass

$('ul li').removeClass(function(n, c) {
      return 'listitem_' + $(this).index();

});

replaceAll()与replaceWith()的差别

replaceAll()    用匹配的元素替换所有匹配到的元素。$("<b>hello</b>").replaceAll("p");

replaceWith()       用新内容替换匹配的元素。$("p").replaceWith("<b>Hello world!</b>");

他们都可以自定义 使用新元素来替换元素 如 $("p").replaceWith(document.createElement("div"));

除此之外replaceWith()还可以使用函数如下

 $("p").replaceWith(function(){
    return "<p>Hello World!</p>";
 });

原文地址:https://www.cnblogs.com/luhangnote/p/2670461.html