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

.last()

.last() 返回: jQuery

描述: 獲取元素集合中最后一個元素。

  • version added: 1.4.last()

如果一個jQuery對象表示一個DOM元素的集合,.last()方法從最后一個匹配元素中構(gòu)造一個新的jQuery對象。

考慮一個頁面上的一個簡單的列表:

<ul>
  <li>list item 1</li>
  <li>list item 2</li>
  <li>list item 3</li>
  <li>list item 4</li>
  <li>list item 5</li>
</ul>

我們可以應(yīng)用此方法設(shè)置列表項:

$('li').last().css('background-color', 'red');

調(diào)用的結(jié)果是最后一個項目為紅色背景。

Example:

Highlight the last span in a paragraph.

<!DOCTYPE html>
<html>
<head>
  <style>.highlight{background-color: yellow}</style>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <p><span>Look:</span> <span>This is some text in a paragraph.</span> <span>This is a note about it.</span></p>
<script>$("p span").last().addClass('highlight');</script>

</body>
</html>

Demo:

jQuery 1.6 API 中文版腳本之家整理、修訂 (2011年6月)
阜南县| 皋兰县| 天全县| 林周县| 登封市| 聊城市| 武汉市| 德州市| 南漳县| 临泉县| 高安市| 色达县| 潞西市| 绵竹市| 麻阳| 赤城县| 易门县| 金川县| 绩溪县| 芮城县| 大名县| 中江县| 舞钢市| 宾阳县| 新宾| 拜城县| 成都市| 灵丘县| 西华县| 富源县| 韩城市| 临城县| 涪陵区| 古浪县| 师宗县| 昂仁县| 武夷山市| 鲜城| 望城县| 新兴县| 贵南县|