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

.first()

.first() 返回: jQuery

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

  • version added: 1.4.first()

如果一個jQuery對象表示一個DOM元素的集合,.first()方法從最后一個匹配元素中構(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').first().css('background-color', 'red');

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

Example:

Highlight the first 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").first().addClass('highlight');</script>

</body>
</html>

Demo:

jQuery 1.6 API 中文版腳本之家整理、修訂 (2011年6月)
五莲县| 乐昌市| 孝感市| 东丰县| 调兵山市| 阿城市| 正宁县| 定结县| 宜丰县| 鸡东县| 宜阳县| 广东省| 西乌珠穆沁旗| 洪江市| 乌兰察布市| 甘泉县| 达孜县| 秦安县| 万全县| 新河县| 贵德县| 榆社县| 安多县| 儋州市| 得荣县| 昭平县| 麻阳| 青冈县| 金山区| 固阳县| 青川县| 阜新市| 宝丰县| 馆陶县| 尉氏县| 泾川县| 巴彦县| 大渡口区| 台安县| 肥城市| 宁安市|