jQuery wrap和wrapAll之间的区别

jQuery .wrap和.wrapAll有什么区别?他们几乎做同样的事情,但可能有什么区别?

解决方法

注意说明的区别:

07000: Wrap an HTML structure around each element in the set of matched elements.
07001: Wrap an HTML structure around all elements in the set of matched elements.

.wrap()单独包装每个元素,但.wrapAll()将它们全部包装成一个组。

例如:

<div class="foo"></div>
<div class="foo"></div>
<div class="foo"></div>

使用$(‘。foo’)。wrap(‘< div class =“bar”/>‘);这发生:

<div class="bar"><div class="foo"></div></div>
<div class="bar"><div class="foo"></div></div>
<div class="bar"><div class="foo"></div></div>

但是使用$(‘。foo’)。wrapAll(‘< div class =“bar”/>‘);这发生:

<div class="bar">
  <div class="foo"></div>
  <div class="foo"></div>
  <div class="foo"></div>
</div>

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...