wrapAll

Module

Methods

dom.wrapAll()
void wrapAll ( selector,wrapperNode )
用 wrapperNode 包装所有符合 selector 的节点
Parameters:
  • selector (string|HTMLCollection|Array<HTMLElement>) – 字符串表示 css3 选择器
  • wrapperNode (HTMLElement) – 包装节点
<div class="container">
  <div class="inner">Hello</div>
  <div class="inner">Goodbye</div>
</div>

after

DOM.wrapAll(".inner",DOM.create('<div class="new" />'));

become

<div class="container">
  <div class="new">
    <div class="inner">Hello</div>
    <div class="inner">Goodbye</div>
  </div>
</div>