Home » jQuery wrapInner()

jQuery wrapInner()

by Online Tutorials Library

jQuery wrapInner()

The jQuery wrapInner() method is used to wrap an HTML structure around the content of each element in the set of matched element. This method can accept any string or object that could be passed to the $() factory function.


Parameters of jQuery wrapInner() method

Parameter Description
wrappingElement It is a mandatory parameter. It specifies what HTML elements are to be wrapped around the content of each selected element. Its possible values are:
  • HTML elements
  • jQuery objects
  • DOM elements
Function(index) It is an optional parameter. It specifies a function that returns the wrapping element.
  • Index:It provides the index position of the element in the set.

Example of jQuery wrapInner() method

Let’s take an example to demonstrate the jQuery wrapInner() method.

Test it Now

You can also use more than one element to wrap the specified content.

jQuery wrapInner() example 2

Test it Now

In the above example we have used three tags altogether:

  • emphasized <em>…</em> tag
  • bold <b>…</b> tag
  • <marquee>…</marquee> tag

jQuery wrapInner() example 3

Test it Now

Next TopicjQuery focus()

You may also like