how can i check how many '.classname' items are? [duplicate]
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()
精彩评论