jQuery wrapAll()Method

jQuery HTML/CSS 方法jQuery HTML/CSS Methods

Example

Wrap all <p> elements inside a <div> element:

$("button").click(function(){ $("p").wrapAll("<div></div>"); });

Try it Yourself »

Definition and Usage

The wrapAll() method wraps all selected elements with the specified HTML element.


Syntax

$(selector).wrapAll(wrappingElement)

Parameter Description
wrappingElement Required. Specifies the HTML element to wrap around the selected elements.

Possible values:

  • HTML element
  • jQuery object
  • DOM element


实例

More Examples

Create new elements using the DOM
How to use document.createElement() to create an element and use it to wrap all selected elements.


jQuery HTML/CSS 方法jQuery HTML/CSS Methods

Other Extensions