jQuery wrapAll() Metodo

❮ Metodi jQuery HTML/CSS

Esempio

Avvolgi un elemento <div> attorno a tutti gli elementi <p>:

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

Definizione e utilizzo

Il metodo wrapAll() avvolge gli elementi HTML specificati attorno a tutti gli elementi selezionati.


Sintassi

$(selector).wrapAll(wrappingElement)

Parameter Description
wrappingElement Required. Specifies what HTML element(s) to wrap around the selected elements

Possible values:

  • HTML elements
  • jQuery objects
  • DOM elements

Provalo tu stesso - Esempi


Come utilizzare document.createElement() per creare un elemento e avvolgilo attorno a tutti gli elementi selezionati.


❮ Metodi jQuery HTML/CSS