jQuery 结构控制的父节点
2018-07-24 11:48 更新
- .wrap() .wrapAll() .wrapInner()
<div class="container"> <div class="inner">Hello</div> <div class="inner">Goodbye</div> </div> $('.inner').wrap('<div class="new" />'); <div class="container"> <div class="new"> <div class="inner">Hello</div> </div> <div class="new"> <div class="inner">Goodbye</div> </div> </div> $('.inner').wrapAll('<div class="new" />'); <div class="container"> <div class="new"> <div class="inner">Hello</div> <div class="inner">Goodbye</div> </div> </div> $('.inner').wrapInner('<div class="new" />'); <div class="container"> <div class="inner"> <div class="new">Hello</div> </div> <div class="inner"> <div class="new">Goodbye</div> </div> </div>
以上内容是否对您有帮助:
更多建议: