jQuery length 屬性

實例

輸出 <li> 元素的數目:

$("button").click(function(){
  alert($("li").length);
});

親自試一試

定義和用法

length 屬性包含 jQuery 對象中元素的數目。

文法

$(selector.length