欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery對象的length屬性用法實例

 更新時間:2014年12月27日 11:25:14   投稿:shichen2014  
這篇文章主要介紹了jQuery對象的length屬性用法,實例分析了length屬性獲取集合中對象數(shù)目的使用技巧,具有一定的參考借鑒價值,需要的朋友可以參考下

本文實例講述了jQuery對象的length屬性用法。分享給大家供大家參考。具體分析如下:

此屬性返回匹配的jQuery對象集合中對象的數(shù)目。

length屬性與size()方法返回相同的值。

語法結(jié)構(gòu):

復(fù)制代碼 代碼如下:
$("selector").length

實例代碼:

復(fù)制代碼 代碼如下:

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.dbjr.com.cn/" />
<title>腳本之家</title>
<style type="text/css">
span{color:red;}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#btn").click(function(){
    $("span").text($("li").length);
  })
});
</script>
</head>
<body>
<div>
  <ul>
    <li>后臺專區(qū)</li>
    <li>前臺專區(qū)</li>
    <li>數(shù)據(jù)庫專區(qū)</li>
    <li>站長交流</li>
  </ul>
</div>
<div>li元素集合中l(wèi)i元素的數(shù)量:<span></span></div>
<button id="btn">點擊查看實例</button>
</body>
</html>

以上代碼可以通過length屬性獲取li元素集合中,li元素的數(shù)量。

希望本文所述對大家的jQuery程序設(shè)計有所幫助。

相關(guān)文章

最新評論