Home  >  Article  >  Web Front-end  >  Usage examples of wrapInner() method in jQuery_jquery

Usage examples of wrapInner() method in jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 16:19:501063browse

The example in this article describes the usage of wrapInner() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

This method wraps the matching element content with the specified HTML content or element.

Grammar 1:

Wrap the content of the matching element with the specified DOM element.

Copy code The code is as follows:
$(selector).wrapInner(elem)

Parameter list:
参数 描述
elem 用于包裹目标的DOM元素。

实例:

复制代码 代码如下:






脚本之家





   
这是div的内容,将会被包裹

   
这是div的内容,将会被包裹

   


语法二:

用函数返回用于包裹匹配元素内容的元素。

复制代码 代码如下:
$(selector).wrapInner(function)

Parameter list:
参数 描述
function 返回用于包裹匹配元素内容的函数。
实例:

复制代码 代码如下:






脚本之家





   
这是div的内容,将会被包裹

   
这是div的内容,将会被包裹

   


语法三:

用html标记代码包裹匹配元素的内容。

复制代码 代码如下:
$(selector).wrapInner(html)

Parameter list:
参数 描述
html 用于包裹匹配元素内容的html标记代码

实例:

复制代码 代码如下:






脚本之家





   
这是div的内容,将会被包裹

   
这是div的内容,将会被包裹

   


希望本文所述对大家的jQuery程序设计有所帮助。

本文转自:蚂蚁部落http://www.softwhy.com/

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn