TUTORIAL前端与浏览器FETCHED
jQuery wrapAll() 方法
jQuery wrapAll() 方法 jQuery HTML/CSS 方法 实例 在 <div> 元素中包裹所有 <p> 元素: [mycode3 type='js'] $('button').click(function(){ $('p').wrapAll(''); }); [/myco..
更新于 2026/7/16
教程详情页默认 noindex。
jQuery wrapAll() 方法
定义和用法
wrapAll() 方法使用指定的 HTML 元素来包裹所有被选元素。
语法
$(selector).wrapAll(wrappingElement)
| 参数 | 描述 |
|---|---|
| wrappingElement | 必需。规定包裹被选元素的 HTML 元素。 可能的值:
|
更多实例
通过 DOM 创建新元素
如何使用 document.createElement() 来创建元素,并用它包裹所有被选元素。
jQuery HTML/CSS 方法