Home >>jQuery Tutorial >jQuery wrap() Method

jQuery wrap() Method

jQuery wrap() Method

jQuery wrap() method in jQuery is used to wraps specified HTML element around each selected element.


Parameter Values

Parameter Description
wrappingElement It is a required parameter and is used to specifies what HTML elements to wrap

Possible values:

  • jQuery objects
  • HTML elements
  • DOM elements
function(index) It Is optional and is used to returns the wrapping element of a specifies function
  • index – Used to returns the index position of the selected element
Here is an Example of jQuery wrap() Method:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<p class="txt1">This is First paragraph.</p>
<p class="txt1">This is Second paragraph.</p>
<button class="btn1">Click here to Wrap a div element</button>