最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

.append()

.append( content ) 返回:jQuery

描述:根據(jù)參數(shù)設(shè)定在每個(gè)匹配元素里面的末尾處插入內(nèi)容。

  • version added: 1.0.append( content )

    content一個(gè)元素,HTML字符串,或者jQuery對(duì)象,用來(lái)插在每個(gè)匹配元素里面的末尾。

  • version added: 1.4.append( function(index, html) )

    function(index, html)一個(gè)返回HTML字符串的函數(shù),該字符串用來(lái)插入到匹配元素的末尾。 Receives the index position of the element in the set and the old HTML value of the element as arguments.

.append()函數(shù)將特定內(nèi)容插入到每個(gè)匹配元素里面的最后面,作為它的最后一個(gè)子元素(last child), (如果要作為第一個(gè)子元素 (first child), 用.prepend()).

.append().appendTo()實(shí)現(xiàn)同樣的功能。主要的不同是語(yǔ)法——內(nèi)容和目標(biāo)的位置不同。對(duì)于.append(), 選擇表達(dá)式在函數(shù)的前面,參數(shù)是將要插入的內(nèi)容。對(duì)于.appendTo()剛好相反,內(nèi)容在方法前面,它將被放在參數(shù)里元素的末尾。

請(qǐng)看下面的HTML:

<h2>Greetings</h2>
<div class="container">
  <div class="inner">Hello</div>
  <div class="inner">Goodbye</div>
</div>

我們可以創(chuàng)建內(nèi)容然后同時(shí)插入到好幾個(gè)元素里面:

$('.inner').append('<p>Test</p>');

每個(gè)新的inner <div>元素會(huì)得到新的內(nèi)容:

<h2>Greetings</h2>
<div class="container">
  <div class="inner">
    Hello
    <p>Test</p>
  </div>
  <div class="inner">
    Goodbye
    <p>Test</p>
  </div>
</div>

我們也可以在頁(yè)面上選擇一個(gè)元素然后插在另一個(gè)元素里面:

$('.container').append($('h2'));

如果一個(gè)被選中的元素被插入到另外一個(gè)地方,這是移動(dòng)而不是復(fù)制:

<div class="container">
  <div class="inner">Hello</div>
  <div class="inner">Goodbye</div>
  <h2>Greetings</h2>
</div>

如果有多個(gè)目標(biāo)元素,內(nèi)容將被復(fù)制然后按順序插入到每個(gè)目標(biāo)里面。

例子:

Example: 在所有的段落里插入一些HTML。

<!DOCTYPE html>
<html>
<head>
  <style>
  p { background:yellow; }
</style>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <p>I would like to say: </p>
<script>
  $("p").append("<strong>Hello</strong>");
</script>

</body>
</html>

Demo:

Example: 在所有段落里插入元素。

<!DOCTYPE html>
<html>
<head>
  <style>
  p { background:yellow; }
</style>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <p>I would like to say: </p>

<script>
  $("p").append(document.createTextNode("Hello"));
</script>

</body>
</html>

Demo:

Example: 在所有段落里插入jQuery對(duì)象 (jQuery對(duì)象類似于一組DOM元素)

<!DOCTYPE html>
<html>
<head>
  <style>
  p { background:yellow; }
</style>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <strong>Hello world!!!</strong><p>I would like to say: </p>
<script>
  $("p").append( $("strong") );
</script>

</body>
</html>

Demo:

jQuery 1.6 API 中文版腳本之家整理、修訂 (2011年6月)
鹿泉市| 新疆| 云南省| 柳江县| 从江县| 阿城市| 黔江区| 顺义区| 康乐县| 馆陶县| 仙游县| 大洼县| 西乌| 望谟县| 五河县| 浙江省| 崇礼县| 随州市| 牡丹江市| 东丰县| 台北市| 五莲县| 西乌珠穆沁旗| 正宁县| 湖州市| 耿马| 朝阳市| 惠安县| 弥渡县| 榆树市| 平顺县| 定襄县| 象州县| 通化市| 迁西县| 类乌齐县| 台南县| 宁晋县| 普安县| 宁阳县| 张家口市|