-

xiyueta().remove() 属性方法

从DOM中删除匹配的元素集
快速上手

xiyueta().remove()属性方法,三种调用方式:
1、xiyueta("div").remove(); //从DOM中删除匹配的元素集
2、xiyueta("div").remove(param1,param2); //参数一为选择器,如 :contains("home") , 参数二为是否删除对象的上部分upHtml文本内容,这个在html替换模板标签时用到,第二个参数为xiyueta.js追加,jQuery里没有第二个参数属性
3、xiyueta("div").remove(param1); //参数一如果为字符串(string)则为选择器,如果为布尔(boolean)类型,则为清空对象上部分 upHtml文本内容(xiyueta.js库追加功能)

总结:xiyueta().remove()用法与jQuery中jQuery().remove()用法保持一致。xiyueta("div").remove();移除同 xiyueta().html(" ","all"); 替换 有所不同,xiyueta().html(" ")设置内容块不能为空,xiyueta().remove()有返回值length
see https://api.jquery.com/remove
尝试一下>>

  • 代码
  • 效果
<script src="https://www.xiyueta.com/js/xiyueta.min.js"></script>
<script>var html = '<ul>\n\
<li>第1条</li>\n\
<li>第2条</li>\n\
<li>第3条</li>\n\
</ul>';
 
xiyueta().parse(html); 
xiyueta("ul li:eq(1)").remove()
$.log(xiyueta.html())
</script>
<ul>
<li>第1条</li>
 
<li>第3条</li>
</ul>