亚洲区国产区激情区无码区,国产成人mv视频在线观看,国产A毛片AAAAAA,亚洲精品国产首次亮相在线

jQuery wrapInner() 方法

jQuery HTML/CSS 方法

wrapInner()方法將指定的HTML元素包裹在每個(gè)選定元素的內(nèi)容周圍。

語(yǔ)法:

在內(nèi)容周圍包裹一個(gè)元素:

$(selector).wrapInner(wrappingElement)

使用函數(shù)將元素包裹在內(nèi)容周圍:

$(selector).wrapInner(function(index))

實(shí)例

將<b>元素包裹在每個(gè)<p>元素的內(nèi)容周圍:

$("button").click(function(){
  $("p").wrapInner("<b></b>");
});
測(cè)試看看?/?

本示例使用document.createElement()創(chuàng)建一個(gè)<b>元素,并將其包裹在每個(gè)<p>元素的內(nèi)容周圍:

$("button").click(function(){
  $("p").wrapInner(document.createElement("b"));
});
測(cè)試看看?/?

使用函數(shù)包裹內(nèi)容:

$("button").click(function(){
  $("p").wrapInner(function(){
      return document.createElement("b");
  });
});
測(cè)試看看?/?

參數(shù)值

參數(shù)描述
wrappingElement指定包圍在每個(gè)被選元素的內(nèi)容周圍的 HTML 元素。

可能的值:

  • HTML元素

  • DOM元素

  • jQuery對(duì)象

function(index)指定一個(gè)返回包裹元素的函數(shù)
  • index-返回元素在集合中的索引位置

jQuery HTML/CSS 方法