jQuery中last()方法用法实例

2019-12-18,,,,,

本文实例讲述了jQuerylast()方法用法。分享给大家供大家参考。具体分析如下:

此方法获取匹配元素集合中的最后一个元素。

语法:
复制代码 代码如下:$(selector).last()

实例:

复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>北冥有鱼</title>
<script type="text/javascript" src="js/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("li").last().css("color","blue")
    })
</script>
</head>
<body>
    <div>
       <ul>
           <li>HTML专区</li>
           <li class="js">Javascript专区</li>
           <li>Div+Css专区</li>
           <li>Jquery专区</li>
      </ul>
    </div>
</body>
</html>

希望本文所述对大家的jQuery程序设计有所帮助。

您可能感兴趣的文章:

  • jQuery初学:find()方法及children方法的区别分析
  • jQuery find和children方法使用
  • jQuery中slice()方法用法实例
  • jQuery中not()方法用法实例
  • jQuery中has()方法用法实例
  • jQuery中map()方法用法实例
  • jQuery中is()方法用法实例
  • jQuery中filter()方法用法实例
  • jQuery中hasClass()方法用法实例
  • jQuery中first()方法用法实例
  • jQuery中children()方法用法实例

《jQuery中last()方法用法实例.doc》

下载本文的Word格式文档,以方便收藏与打印。