开发者

how can i check how many '.classname' items are? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Count elements with jQuery

hi there,

i was considering, using jquery,

var n = 0;
$('.className').each(function(){
     n =开发者_JAVA技巧 n+1;
});

Any better solution in mind?

thanks!


Use the length property:

$('.className').length


$('.className') is an array, so you can use .length.

$('.className').length


Use .length or .size properties:

$('.className').length

$('.className').size()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜