wrapInner

Module

Methods

dom.wrapInner()
void wrapInner ( 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.wrapInner(".inner",DOM.create('<div class="new" />'));

become

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