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

jQuery中size()方法用法實(shí)例

 更新時(shí)間:2014年12月27日 11:08:42   投稿:shichen2014  
這篇文章主要介紹了jQuery中size()方法用法,實(shí)例分析了size()方法返回對(duì)象集合中元素?cái)?shù)目的使用技巧,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了jQuery中size()方法用法。分享給大家供大家參考。具體分析如下:

此方法可以返回jQuery對(duì)象集合中元素的數(shù)目。

size()方法的返回值與jQuery對(duì)象的length屬性一致。

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

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

實(shí)例代碼:

復(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").size());
  })
})
</script>
</head>
<body>
<div>
  <ul>
    <li>后臺(tái)專區(qū)</li>
    <li>前臺(tái)專區(qū)</li>
    <li>數(shù)據(jù)庫(kù)專區(qū)</li>
    <li>站長(zhǎng)交流</li>
  </ul>
</div>
<div>li元素集合中l(wèi)i元素的數(shù)量:<span></span></div>
<button id="btn">點(diǎn)擊查看實(shí)例</button>
</body>
</html>

以上代碼能夠計(jì)算li元素的數(shù)量,并輸出。

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

相關(guān)文章

最新評(píng)論