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

.andSelf()

.andSelf() 返回: jQuery

描述: 添加先前的堆棧元素集合到當前組合。

  • version added: 1.2.andSelf()

在討論中所描述的.end()以上,jQuery對象維護一個內部棧,不斷變化的跟蹤對應匹配的元素。當DOM遍歷的方法之一被調用,一組新的元素被推入堆棧。如果前一組元素是理想的好, .andSelf()可以提供幫助。

考慮一個面頁中簡單的列表和它之后的段落:

<ul>
   <li>list item 1</li>
   <li>list item 2</li>
   <li class="third-item">list item 3</li>
   <li>list item 4</li>
   <li>list item 5</li>
</ul>

如果我們在第三個項目開始,我們可以找到它之后的元素來:

$('li.third-item').nextAll().andSelf()
  .css('background-color', 'red');

此調用的結果是一個項目3,4和5個紅色背景。首先,最初的選擇位于第3項,初始化堆棧,僅包含此項目集。在調用.nextAll()然后推棧設置項目4和5上。最后, .andSelf()調用這兩套合并在一起,創(chuàng)建一個jQuery對象,在所有三個項目文件順序點:{[<li.third-item>,<li>,<li> ]}.

Example:

Find all divs, and all the paragraphs inside of them, and give them both classnames. Notice the div doesn't have the yellow background color since it didn't use andSelf.

<!DOCTYPE html>
<html>
<head>
  <style>
  p, div { margin:5px; padding:5px; }
  .border { border: 2px solid red; }
  .background { background:yellow; }
  </style>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <div>
    <p>First Paragraph</p>
    <p>Second Paragraph</p>
  </div>
<script>
    $("div").find("p").andSelf().addClass("border");
    $("div").find("p").addClass("background");

</script>

</body>
</html>

Demo:

jQuery 1.6 API 中文版腳本之家整理、修訂 (2011年6月)
利津县| 汉沽区| 额济纳旗| 阿拉善右旗| 莱阳市| 哈巴河县| 大姚县| 涡阳县| 乌拉特后旗| 榕江县| 济宁市| 博白县| 遵义市| 兴仁县| 旬邑县| 留坝县| 潜江市| 驻马店市| 云阳县| 即墨市| 平和县| 乐平市| 湖南省| 延寿县| 永登县| 木兰县| 噶尔县| 郁南县| 东安县| 明溪县| 曲麻莱县| 湖北省| 志丹县| 洪洞县| 湖北省| 丹寨县| 股票| 浙江省| 墨江| 上杭县| 库车县|